The Close By function allows you to close two opposite positions on the same instrument against each other. For example, if you have both a BUY and a SELL position open on XAUUSD, Close By can be used to close those positions simultaneously.
This function is available on hedging accounts where opposite positions on the same instrument can be held at the same time.
How does Close By work?
When Close By is used, MetaTrader does not close each position separately at the current Bid and Ask prices.
Instead, the opening price of one position is used to close the opposite position, and vice versa. This allows the two positions to be offset against each other and can avoid paying the spread twice compared with closing each position individually.
For example:
BUY 0.10 lot XAUUSD
SELL 0.10 lot XAUUSD
Using Close By will close both positions against each other.
If the positions have different volumes, only the matching volume will be closed. The difference will remain as an open position in the direction of the larger trade.
Using Close By on MT5 for PC/Mac
Open the Trade tab from the Toolbox window:
Locate the position you want to close. If you are closing a Buy position, make sure you have an open Sell position for the same instrument, and vice versa.
Double-click the position and select Close By:
Select the corresponding opposite position you want to close against:
Carefully review the two selected positions to ensure they are correct.
Click Close to submit the Close By instruction:
Using Close By on MT4 for PC/Mac
Open the Trade tab from the Terminal window:
Locate the position you want to close. If you are closing a Buy position, make sure you have an open Sell position for the same instrument, and vice versa.
Double-click the position to open the order execution window.
Click the drop-down menu under the Type field:
Select Close by.
Select the corresponding opposite position you want to close against:
Click Close to submit the Close By instruction.
Using Close By on MT4 and MT5 Mobile
Open the Trade section in the MT5 mobile application.
Select or press and hold the position you want to close.
Select Close By from the available trading options:
Choose the opposite position you want to close against:
Review the positions and tap Close:
On mobile, the Close By option is only available for hedging accounts when an opposite position for the same instrument is available.
How does Close By appear in my trade history?
A Close By transaction may appear differently from a normal market closure.
MetaTrader records the transaction as a Close By order, while the corresponding deals may appear as “out by” in the trading history.
The closing price displayed for one position may also correspond to the opening price of the opposite position rather than the market price shown on the chart at the time the Close By instruction was submitted.
Additionally, the combined profit or loss from the Close By operation may be displayed on only one of the associated deals. As a result, one of the positions may show a profit/loss of 0.00, while the other position reflects the combined profit or loss from the Close By operation.
This is standard MetaTrader behavior and does not mean that one of the positions was closed without a profit or loss calculation.
Important disclaimer
Please review the position ticket numbers, trade direction, and volumes carefully before confirming a Close By instruction.
Close By is different from closing an individual position at the current market price. Selecting this function instructs the platform to offset the chosen position against an eligible opposite position.
If the two positions have different volumes, the unmatched portion of the larger position will remain open. The prices and profit/loss presentation shown in your trade history may also differ from a standard market closure because of the way MetaTrader records Close By transactions.
If you wish to close a position normally at the available market price instead, please use the regular Close Position function rather than Close By.
