Home / Blog / Locking a position in forex: what a lock freezes and what it…

Locking a position in forex: what a lock freezes and what it costs

In short: A lock is an opposite order of the same size. It freezes the floating loss but does not close it, costs spread and swap, and you still need a way out.

Locking a position: −$39.70 floating loss a lock freezes on a full 11-order basket; spread and swap still cost
−$39.70 floating loss a lock freezes on a full 11-order basket; spread and swap still cost

Locking a position means opening an opposite order of the same size on the same symbol, on a hedging account. While both stay open, price moves cancel out and the floating result of the locked volume stops changing. Nothing is closed: the loss is still there, the lock costs spread and possibly swap, and you still have to get out.

The numbers below are arithmetic of the settings, not a forecast. They use the Midas default grid from our grid calculator: cent account, $1,000 balance, start lot 0.01, ×2, 11 orders, $1.95 step, first order at $4,170, leverage 1:2000, stop-out 40%, calculated on 8 October 2026. With all 11 orders open, the basket holds 20.47 lots and floats at −$39.70. That is the position we lock.

One simplification: the calculator's spread field is 0, so −$39.70 leaves out the spread of the 11 buys themselves. The tables add a single assumed gold spread of $0.30, on the lock order only. Swap is ignored.

See also: 7 protections for a martingale grid bot on gold →

On this page (10)

What is a lock (hedge-lock) in forex?

A lock (hedge-lock) in forex is an opposite position in the same symbol and the same volume as a position you already hold, opened on a hedging account: if you are long 20.47 lots of gold, you sell 20.47 lots. Traders also say "hedge lock" or "direct hedge".

Why does it freeze anything? A buy of L lots at an average price a earns L × (p − a) at the current price p. A sell of L lots opened at b earns L × (b − p). (On this cent account one lot moves $1 per $1 of gold, so lots and dollars line up.) Add them: L × (b − a). The price p has dropped out, and what remains was fixed when the lock opened.

Think of pausing a video: the picture stops, but the battery keeps draining. Spread and swap are the battery, and margin stays tied up. A lock pauses price risk. It repairs nothing.

Which MT5 accounts allow a lock?

Only hedging accounts in MetaTrader 5 allow a lock. On a netting account an opposite deal shrinks, closes or reverses the single common position (MetaTrader 5 Help), so a lock cannot exist.

MT5 has two position accounting systems, and the broker sets which one your account uses. With hedging, every deal opens its own position, opposite ones included. Hedging vs netting in MT5 shows how to check yours.

Rules differ by country as well. Under Compliance Rule 2-43(b) of the US National Futures Association (NFA), forex dealer members may not carry offsetting positions in a customer account and must offset them first-in, first-out. Check that the broker accepts clients from your country and what it allows.

Does locking a losing trade stop the loss?

A lock stops the floating loss on the locked volume from growing, but it does not close or shrink it: price moves on that volume cancel out, while spread, swap and margin keep costing. The numbers below show it.

Sell 20.47 lots at the price of the 11th order. Equity was $960.30 (balance $1,000 minus the $39.70 floating loss). The new order pays its spread at once: 20.47 lots × $0.30 = $6.14, so equity is $954.16. Now move gold:

Gold moves from the lock levelEquity without a lockEquity with the lock
no move$960.30$954.16
down $10$755.60$954.16
down $30$346.20$954.16
down $46.08$17.04, below the $17.07 stop-out line$954.16
up $1.94 (basket break-even)$1,000.00$954.16

Read the last row twice. A $1.94 bounce would have wiped out the basket's loss. With the lock open it changes nothing, because the sell order loses what the buys gain. A lock freezes the recovery as firmly as it freezes the loss.

What does a lock cost: spread, swap and margin?

A lock costs the spread of the new order at once, swap on both positions while it stands, and margin that depends on the broker's hedged-margin rule.

Spread. The lock is a new order. It opens at the bid and is valued at the ask, so equity drops by spread × lots at once: 20.47 × $0.30 = $6.14 on a cent account. If your account charges commission, it applies to the lock order as well.

Swap. Swap belongs to each position. MQL5 keeps a cumulative swap per position (POSITION_SWAP), and every symbol has separate long and short values (SYMBOL_SWAP_LONG, SYMBOL_SWAP_SHORT) that apply when a position is carried to the next trading day. A lock holds two positions, so both can be charged, or one charged and one credited. Read your specification; spread and swap on gold has more.

Margin. MT5 Help sets the margin of opposite positions through the "Hedged margin" field of the symbol specification, and says the broker determines the calculation method. For a full lock of our 20.47 lots:

Rule for the covered volumeMarginMargin levelStop-out line (40%)
Before the lock$42.682,250%$17.07
Larger leg, or hedged value = contract size$42.682,236%$17.07
Hedged margin = 0$0nothing to divide bynone
Both legs charged in full$85.361,118%$34.14

The last row is a cautious planning case, not a claim about any broker. MT5 Help leaves the value for the covered volume to the broker, so a rule that charges both legs cannot be ruled out in advance. Then margin doubles, the margin level halves and the stop-out line doubles, although price no longer moves your equity. Find your row in Market Watch, Specification, or ask the broker.

Does a lock prevent a stop-out?

A lock removes price risk only on the volume it covers, so with equal volumes price alone cannot push equity toward the stop-out line, but it does not prevent a stop-out outright.

Four things still can: the spread paid (and commission, if charged) when the lock opens, swap while it stands, volume added after the lock, and the moment you take the lock off.

A half lock shows the middle case. Selling 10.24 of the 20.47 lots leaves $10.23 exposed per $1, and the room to stop-out after the 11th order grows from $46.1 to about $91–93, depending on the margin rule: roughly double, not unlimited. The Midas help pages say it plainly: the lock does not prevent a stop-out. The level itself is explained in Margin call vs stop-out in MT5.

How do you leave a lock?

To leave a lock you close at least one leg, and which leg you close is a view on where gold goes next. Closing both legs makes the frozen result final; closing one leg leaves an ordinary open position. Suppose gold fell another $10 after the lock. The sell leg is up $204.70 before its spread, the buy basket is down $244.40, and equity is $954.16 after the $6.14 spread.

ExitBecomes finalYou hold afterwards
Close both with Close By−$39.70, the frozen resultnothing
Close both one by one−$45.84, the same plus the spread of the locknothing
Close only the sell leg+$198.56 (+$204.70 minus the spread)the buy basket again at −$244.40; gold must rise $11.94 from where you closed, which is $1.94 above the lock level, plus spread
Close only the buy leg−$244.40a naked 20.47-lot sell: a bet that gold keeps falling
Shrink both legs in stepsa slice of the frozen result, plus spread per stepa smaller locked pair

MT5 Help describes Close By: it closes two opposite positions against each other and, in its words, saves one spread, because each position closes at the open price of the other. That is the gap between the first two rows. If the volumes differ, one position stays open with the difference. Close By pairs two positions at a time, so one sell against eleven buys takes eleven steps. Ask your broker whether Close By deals carry commission.

Whichever leg stays, you hold an ordinary position with ordinary risk. The lock postponed the decision. It did not make it.

How is a lock different from closing a trade or a stop-loss?

Closing a trade and a stop-loss make the loss final; a lock keeps the position open and delays the decision, at the price of spread, swap and margin.

Close nowStop-lossLock
Loss becomes finalYesYes, when hit (a fast market can fill worse)No, frozen
CostsOne spreadOne spread, maybe slippageSpread now (and commission, if charged), swap while open, margin per broker rule
Second decision neededNoNoYes: when and how to leave

These are different tools for different questions, and none is right in general. Closing and a stop-loss make the loss final to stop the clock. A lock keeps the position and delays the decision, at a price. What fits depends on how much loss you can accept as final and whether the exit is planned first.

What is a hedge grid EA, and where does Midas's optional lock fit?

A hedge grid EA is a grid EA that can open a lock, an opposite order on a hedging account, to freeze the floating result of part of its basket.

Midas is an Expert Advisor for MetaTrader 5 that trades gold with a grid. It runs on hedging cent accounts, and netting accounts are not supported because the lock needs opposite positions held at once. The lock is optional: it can cover a fraction of the basket (for example 1/4 or 1/2) or all of it (1:1), armed by hand or by rules (basket loss, order number, room to stop-out). While it stands, floating loss on the locked part stops growing. The unlocked part and the spread paid on every reduction still count, a stop-out remains possible, and the lock does not create profit or promise the locked amount back. See Risk, plainly, Panel settings explained and the FAQ.

What can go wrong?

  • Too late. Depending on the hedged-margin rule, the lock order needs margin too. When equity is thin, the server can refuse it (MQL5 return code 10019, "not enough money to complete the request") exactly when you want it.
  • Too small or uneven. A lock covers only the volume that existed when it opened; orders added later are not covered.
  • Holding costs and the exit. Swap keeps accruing, so a flat equity line can hide a slow leak. And there are two decisions, when to lock and when to unlock, and each can be wrong.
  • Close-out order. The MQL5 book describes the stop-out level as the one at which the most unprofitable position is forced to close, and says nothing about locked pairs. If a server applies that literally after a fall, a losing buy goes first and the winning sell can be left open alone. How your broker closes locked positions is in its terms: read them.
  • False calm. A steady equity line is not insurance. A martingale grid, locked or not, can hit a stop-out if the deposit is too small. Size your deposit with a safety margin.

This is arithmetic of the settings, not a forecast. A lock is not insurance and does not recover a loss. Trading with leverage carries risk: if the deposit is too small, a stop-out is possible. Size your deposit with a safety margin. Nothing here is individual investment advice.

Midas · figures calculated and sources retrieved on 8 October 2026. Related: grid EA glossary, martingale grid on gold.

FAQ

Does hedging a trade stop losses?

Only on the part you hedge, and only while the hedge stays open. An opposite order of the same size cancels price moves on that volume, so the floating loss stops growing but does not shrink. Swap keeps accruing, and closing the hedge either makes the loss final or brings the price risk back.

How do I hedge a losing trade in forex?

On a hedging account, open an opposite order in the same symbol: the same volume for a full lock, a smaller one for a partial lock. First check your account's hedged-margin rule, whether free margin covers the new order and how you will leave the lock. This explains how it works, not a suggestion to do it.

What is a locked position in MT5?

On the Trade tab, a locked position appears as two positions of the same symbol, one buy and one sell, usually of equal volume. Each carries its own profit and swap. To leave, close them one by one or use Close By, which closes the two against each other and, per MT5 Help, saves one spread. Close By is available only on hedging accounts.

Does a locked position pay swap and margin?

Swap: each position is charged at rollover by its own long or short value, so the net can be a cost or a credit; check your broker's terms for locked positions. Margin: it depends on the "Hedged margin" field of the symbol specification, which can mean the larger leg, a set value or zero. Read both in your own specification instead of assuming.

What is a hedging martingale or hedge grid EA?

"Hedging martingale" and "hedge grid" are market labels, not standard terms. Here a hedge grid EA means a grid EA that can open a lock: an opposite order of the same size on a hedging account that freezes the floating result of the locked part. A lock costs spread, swap and margin and does not prevent a stop-out. Midas, an MT5 gold grid EA, has an optional lock that can cover 1/4, 1/2 or all of the basket.