In this article
After this article, you can
- Identify an actual FIFO account rule separately from spreadsheet allocation.
- Build the queue and check confirmations and remaining exposure.
Terms at hand: Hedging · Order execution · Stop loss
A FIFO closing rejection in MT5 means you must check the position order permitted on the actual account. FIFO, or “first in, first out”, can be a server constraint rather than your chosen journal allocation method. Do not automatically resend the same close or close an older position without checking the plan. Preserve the reply, account mode and current positions in that exact symbol first. This rule does not automatically apply to every platform user or every jurisdiction.
Which FIFO: the account rule or your analysis?
MT5 exposes ACCOUNT_FIFO_CLOSE. True indicates closing a symbol's positions in opening order, oldest first; outside hedging accounting mode this property is false. The reading describes the actual account rather than the country selected for interface language. Establish the provider and account conditions instead of assuming that MT5 imposes FIFO everywhere.
Separately, FIFO can be an analytical convention allocating a reduction to earlier entries. You can use such a convention when analysing one shared netting position, but a spreadsheet does not change which close the server accepts. The netting strategy-attribution guide covers allocation. This article concerns the technical order of closing actual positions.
What should you inspect after a rejection?
Read the complete request reply. Code 10045, TRADE_RETCODE_FIFO_CLOSE, identifies rejection associated with the account's FIFO setting. A generic closing-error label cannot distinguish order from price, volume or connection problems. Do not confuse it with a separate restriction on opposite positions or an instrument's close-only mode.
Record server, an account alias, exact symbol, position ticket, opening time and current volume. Sort only that instrument's positions by time rather than profit. A display sorted by another column does not establish precedence. If visible timestamps are identical at the displayed resolution, preserve identifiers and clarify ordering with the provider instead of inventing a ticket-number rule.
What does a three-position sequence look like?
| Position | Opening | Volume | Opening price | P/L at Bid 1.1030 |
|---|---|---|---|---|
| P1 | 08:00 | 0.10 lot | 1.1000 | 30 USD |
| P2 | 08:05 | 0.20 lot | 1.1010 | 40 USD |
| P3 | 08:10 | 0.10 lot | 1.1020 | 10 USD |
In this model, requesting P3's closure before P1 violates the sequence. After P1 is confirmed fully closed, P2 is next rather than P3. P2 has the largest profit but was not initially the oldest. Smallest volume does not select the next position either. Read the actual state after execution to confirm which remaining position now comes first.
Opening order, rather than profit order
Total profit before closing is 80 USD. With prices fixed, closing P1 gives 30 USD realised and 50 USD floating on P2 and P3. After also closing P2, those amounts are 70 and 10 USD. The model sum remains 80 USD; its allocation changes without creating another profit. Actual fees and price changes can alter these numbers.
Why not replace the request with a close of the oldest position?
You may want to exit a specific position because it belongs to a separate plan or EA. Automatically closing a different position changes that plan even if the request satisfies the account constraint. Confirm the intended symbol, direction, quantity and effect on total exposure. If account conditions conflict with the plan, diagnosis may require reorganising the trading process rather than immediately sending a substitute transaction.
Do not try to bypass the restriction by opening an opposite position. Hedging can create new exposure, and the account may also prohibit opposite positions. After a partial close, read remaining volume and ordering again. Sending a request does not establish that the oldest position disappeared completely. The order-error guide explains reconciliation after uncertain replies.
A queue prepared before sending is only a plan. Another accepted operation can change the account before your next request, so keep the planned sequence separate from confirmed execution records. If a close fails, preserve that failure and re-read state rather than continuing with ticket assumptions from an old table.
Mark whether a person, EA or server-side mechanism initiated the operation. The symbol alone does not identify the request source. This helps compare the planned queue with actual history and avoids blaming a manual close for an unrelated server event. Preserve uncertain outcomes explicitly rather than treating every request in an old table as confirmed.
Does FIFO affect stops and bulk closing too?
MT5 Help for FIFO accounts describes linked stop-loss and take-profit levels across positions in the same instrument so exits preserve order. Do not assume each position can have wholly independent protection on that account. After changing a level, inspect the values actually accepted for every related position.
The same documentation describes sequential FIFO closing and interruption when an error occurs. A bulk command does not establish that all positions closed. Preserve replies and inspect positions still open instead of resending the entire set. Stop-out liquidation needs its own account-specific check; our example does not prescribe forced-liquidation order for every provider.
“positions can only be closed by FIFO rule” — MetaQuotes, MQL5 Reference, ACCOUNT_FIFO_CLOSE description; accessed 13 October 2026.
What to do tomorrow
- Preserve the reply and account setting. Record the complete retcode, exact symbol and ACCOUNT_FIFO_CLOSE value on the relevant account. Keep this separate from your chosen transaction-analysis method. Do not include personal details or a password in the diagnostic record.
- Build a queue from actual state. Make a table for that symbol with identifier, opening time, direction, volume and accepted protection levels. Mark the oldest position and uncertain replies. Reconcile history before another request instead of sorting positions by profit or assuming an old queue remains valid.
- Check the model without live orders. Recalculate P1, P2 and P3, including the 30/50 USD split after the first closure. To reproduce platform behaviour, use a matching demo and inspect every outcome. This guide does not recommend closing any particular position.
Check your understanding
One short exercise
About 3 min · you can try again
FIFO=true: P1 08:00, P2 08:05, P3 08:10. P2 has the largest profit. Which is first in the full-close model?
- P2 because it releases the most profit.
- P1 because it is oldest in that same symbol.
- P3 because the newest history row comes first.
Check the answer and explanation
P1 because it is oldest in that same symbol.
Correct. Re-read remaining positions after its full close is confirmed.
Frequently asked
Does FIFO prohibit hedging on every MT5 account?
No. FIFO here is a closing-order property of a specific account. Restrictions on opposite positions are separate and may coexist with it. Do not apply one provider’s offering to every account, platform or country. Check position accounting mode, ACCOUNT_FIFO_CLOSE, permissions and the agreement. A hedging label does not guarantee unrestricted opening and closing. Diagnosis should identify the actual rejection reply instead of attributing it to a generic legal rule without checking scope.
Does FIFO in my netting spreadsheet change the server rule?
No. An analytical method allocates entries, exits and profit using a chosen convention. It does not establish which requests the server accepts for actual account positions. A valid journal can coexist with a request rejected for another reason. Preserve execution facts separately from the allocation method. ACCOUNT_FIFO_CLOSE in this guide describes a technical MT5 account setting rather than journal column names, a win-rate calculation or a local tax-accounting rule.
Can I send an opposite order instead of closing the oldest position?
Do not treat an opposite order as a safe workaround. On a hedging account it can create a new position, while the account may also prohibit opposite positions. Its effect then differs from closing the selected ticket. Establish the exposure you intend to remove and the account’s permitted operations first. After an uncertain reply, inspect actual positions and history. This guide explains ordering checks rather than recommending automatic replacement orders or removal of accepted protection.
Can I assume the account is flat after a close-all command?
Not without checking confirmed executions and actual state. Documentation describes sequential FIFO closing and interruption on error, so some positions may remain open. Preserve each stage’s result, retrieve the current position list and determine what needs clarification. Do not resend the whole set merely because the display did not immediately show the expected outcome. Inspect remaining exposure and accepted stops after a bulk operation too; a command is different from evidence that every exit completed.
Sources & bibliography
-
MetaQuotes Ltd MQL5 Reference — Account Properties · ACCOUNT_FIFO_CLOSE, per-symbol ordering and false outside hedging. www.mql5.com ↗
-
MetaQuotes Ltd MQL5 Reference — Trade Server Return Codes · 10045 TRADE_RETCODE_FIFO_CLOSE distinct from other restrictions. www.mql5.com ↗
-
MetaQuotes Ltd MetaTrader 5 Help — Executing Trades, FIFO closing · FIFO, linked stop-loss/take-profit levels and sequential bulk operations. www.metatrader5.com ↗
