MetaTrader 5 Close By: How Opposite Positions Can Save One Spread
MetaTrader 5’s Close By instruction offsets two opposite positions on the same symbol in an eligible hedging account and can save one spread compared with closing each independently. It is a broker-server trading operation rather than a chart overlay. The matched portion closes; if the two open lots differ, the larger position retains the excess volume.
MetaQuotes documents Close By and its ‘out by’ accounting in its official trading manual and mobile Close By guide. This is different from our pending-entry OCO guide: Close By works on existing open opposing positions, not untriggered entry orders.
| Input | Value | Result |
|---|---|---|
| Open EUR/USD buy | 0.30 lot | Larger ticket |
| Open EUR/USD sell | 0.20 lot | Smaller opposing ticket |
| Matched Close By | 0.20 lot | Offsets both tickets |
| Residual position | 0.30 − 0.20 | 0.10 lot long |
| Model residual sensitivity | 0.10 × $10/pip | $1 per pip |
Example symbols and cash figures are fictional; current broker contract rules must be verified.
A Close By request needs a hedging account and opposing tickets
MetaTrader accounts can run in netting or hedging modes. In netting mode an opposite deal ordinarily reduces or closes a single aggregate position, so two separate EUR/USD buy and sell tickets normally do not coexist for Close By. In hedging mode the trader can have independent long and short tickets for the same exact broker symbol and can select a qualifying opposite ticket for the special offset operation when the server permits it.
On desktop, open a position from the Trade tab, choose Close By in the Type field and select the opposite ticket. Confirm actual position IDs, symbols, volumes, and any broker-specific permissions. A long on EURUSD cannot be assumed compatible with a short on EURUSDm or another broker product. The absence of Close By from an app’s menu can signal unsupported symbol/order permissions, account accounting mode, or app limitations rather than an error that reinstalling the client fixes.
How one saved spread arises
Closing a regular long requires selling at the current Bid; closing a regular short requires buying at the Ask. If both hedged tickets are closed separately at simultaneous quotes, the combined exit cost relative to the midpoint is one full spread. Close By instead uses the opening price of the opposite ticket as the closing reference for the matched portion, avoiding one current dealing spread compared with the two independent exit executions, under eligible broker accounting.
For a purely hypothetical two-pip EUR/USD spread and a matched one standard lot worth approximately $10 per pip, the saved exit spread is about 2 × $10 = $20, before any explicit Close By commission. For the 0.20-lot matched volume in the example below, a two-pip spread represents $4. For example, if the buy opened at 1.1000 and the sell at 1.0950, the matched price loss is $100 through Close By, versus $104 at simultaneous Bid 1.0970 and Ask 1.0972, excluding fees. It does not refund the spread already incurred on opening either position or erase historical losses and overnight swap charges.
A 0.30 long versus 0.20 short produces a 0.10 residual
Suppose EUR/USD has an accepted 0.30-lot buy and an independent 0.20-lot sell. The server can match the smaller 0.20-lot quantity. The remaining direction is that of the larger ticket: 0.30 − 0.20 = 0.10 lot long. Under a conventional standard €100,000 forex lot, its approximate EUR/USD exposure is $1 per pip, compared with the original long’s $3 per pip.
For a hypothetical ten-pip adverse move after Close By, the residual gross price loss would be about $10. The trader must check the residual ticket, Stop Loss, financing and margin because the account retains its original net 0.10-lot long exposure. Equal-sized opposing tickets would instead produce no residual quantity.
Why the history shows two out-by deals but perhaps only one P/L entry
MetaQuotes records the Close By operation with an order and two special out-by deals that refer to the paired original positions. MetaTrader records the combined price profit or loss on one of the two deal rows rather than splitting it between them. An exported spreadsheet that sums each displayed closing row as though both contain the full realised gain risks double counting; a trader who ignores the companion zero-P/L row might mistakenly infer no trade took place.
Reconcile the two original opening IDs, matched quantity, resulting residual position, realised combined P/L, and explicit commission/swap entries. Use our MetaTrader deal-history guide for distinguishing deals, orders and account equity.
Why a hedged loss does not disappear after Close By
Imagine a long entered before a currency decline and a short entered later as a temporary ‘lock’. The long’s prior decline remains reflected in account equity even while the two legs roughly offset subsequent directional movement. Executing Close By realises the combined result subject to the two opening prices; it does not move either ticket’s historical entry back to market or generate risk-free profit by matching a winner against a loser.
Any borrowing charges or rollover credits accumulated while both positions were open remain in the final account ledger. See opposing forex positions and swap costs for the full cost reconciliation.
Operational mistakes that change exposure
A trader might select the wrong opposite ticket when there are multiple hedged positions in the same symbol, or request a new opposite market order instead of using the Close By function. The latter can simply open another short in a hedging account and increase gross exposure rather than close the intended pair. A broker’s server may also reject Close By on an unsupported symbol; a request submitted from the client is not proof the offset succeeded.
Check the immediate server reply, final order history and remaining open positions before placing any further trade. An EA issuing repeated Close By requests after communication timeouts should reconcile actual positions on each callback to avoid over-offsetting.
A seven-step Close By decision checklist
- Verify the account is MT5 hedging rather than netting and Close By is supported.
- Identify the exact opposing tickets and symbol.
- Calculate the matched smaller volume and possible residual larger-side position.
- Estimate saved one-spread cash amount from current quote and contract size.
- Check whether the broker applies Close By fees or restrictions.
- Confirm accepted Close By and both out-by deal records.
- Reconcile realised P/L, financing and any remaining directional exposure or stops.
The facility is a cost-efficient exit mechanism in suitable circumstances, not a standalone trading strategy or a guarantee that hedging is profitable.
After Close By, confirm the two out-by deals and the remaining position ticket. The matched volume can save a spread relative to separate closes, but any residual volume still carries market risk and the earlier loss remains part of total account performance.
Frequently asked questions
Does MT5 Close By work on all accounts?
No. It requires eligible hedging positions and broker/server support.
How much spread does Close By save?
MetaQuotes states one spread can be saved on the matched volume relative to closing both positions independently.
Will Close By eliminate both positions if volumes differ?
No. The unmatched difference remains in the larger position’s direction.
Why do I see two out-by deals?
MT5 records a linked pair; its combined realised result may be shown on one deal row.
Is Close By an OCO order?
No. OCO concerns cancellation of linked pending entries, a different mechanism.
Official references
Education only: Not a trade recommendation. Verify actual instrument, broker legal entity and account terms before deciding any trading action.
Stay Ahead of the Markets
Subscribe free for market research, a weekly digest option and your complimentary Professional Trader’s Research Checklist.