Page 1 of 1

Close By in MT5 and closing two opposite positions for one spread

Posted: Mon Oct 19, 2026 8:57 am
by Fairman
Close By in MT5 and closing two opposite positions for one spread

If you trade on an MT5 hedging account, or MT4, there's a function called Close By that a lot of people don't know exists.

The idea is simple. You have a buy and a sell open on the same symbol. Instead of closing each one separately, which means each closing trade crosses the spread, Close By closes one against the other. The two positions offset each other at their own prices, and you avoid paying the spread on a second exit.

Where this comes up for scalpers is mostly when hedging during a news spike, when running two strategies that end up on opposite sides of the same pair, or when you add a position the other way to lock a level and later want out of both.

To use it in MT5, open the order window from one of the positions, choose Close By as the type, and pick the opposite position from the list. The sizes don't need to match. If one is bigger, the leftover part stays open.

A couple of things to check with your broker. Some charge commission on Close By the same as a normal close, so the saving is just the spread. Some account types don't allow it at all. And on a netting account it doesn't apply, because you can't hold opposite positions in the first place.

Re: Close By in MT5 and closing two opposite positions for one spread

Posted: Tue Oct 20, 2026 8:30 pm
by Fairman
The saving is real but it isn't big on tight spreads. On EURUSD with a raw account, the spread you save might be a fraction of a pip. Where it adds up is on wider instruments like gold, indices or the minor crosses, or during the hours when spreads widen. If you hold opposite positions often, it's easy to estimate the yearly saving from your own history: count the times you closed both legs of a hedge separately and multiply by the typical spread at those times. That number tells you if it matters for you at all.

Re: Close By in MT5 and closing two opposite positions for one spread

Posted: Wed Oct 21, 2026 8:46 am
by Fairman
Some traders use Close By deliberately as a way to exit during spread spikes. If you're in a position and want out during a moment when the spread is very wide, opening an opposite position locks the current price, and you can close both later with Close By once spreads normalise. You still pay the wide spread once when opening the hedge, so it doesn't make the exit free. It just stops the position from moving further while you wait. Whether that's better than simply closing depends entirely on how long the spike lasts. In practice most spikes fade within a minute or two.

Re: Close By in MT5 and closing two opposite positions for one spread

Posted: Thu Oct 22, 2026 5:48 am
by Fairman
Check how the result shows up in your account history. With Close By, the deal records can look a bit odd at first, with both positions closed at the open price of the other one. If you export history into a journal or a spreadsheet, make sure your tool handles these deals correctly. Some journaling tools misread them and show a strange profit or loss split between the two legs, even though the combined result is right. Run a quick test on a demo before relying on any automated stats. A single odd looking trade in the stats is easy to spot, but fifty of them quietly distort the averages.

Re: Close By in MT5 and closing two opposite positions for one spread

Posted: Thu Oct 22, 2026 6:07 am
by Fairman
For EA builders, MQL5 has a dedicated request type for this. The trade request uses TRADE_ACTION_CLOSE_BY with the ticket of the position and the ticket of the opposite one. It's easy to add to an EA that hedges, and it can make the exit logic cleaner since you don't need two separate market orders. Test it in the strategy tester and on demo first, because some brokers reject it on certain account types and your EA needs to handle that reject and fall back to normal closes. A demo account is the place to find out.

Re: Close By in MT5 and closing two opposite positions for one spread

Posted: Sun Oct 25, 2026 9:40 am
by FXS HongKong Scalper
Worth adding that Close By only exists on hedging accounts in MT5. On a netting account the opposite order simply reduces or reverses the position, so the lock does not happen. Also check how swap is charged if the hedge stays open past rollover, since both legs are charged swap and the spread around rollover is usually the widest of the day. For a spike during the Asian morning, for example a surprise from the Bank of Japan or a Chinese data release, the wide spread can last longer than a minute or two, so the hedge can end up sitting through a much longer wait.