MT4 error 150: Prohibited by FIFO rules (ERR_TRADE_PROHIBITED_BY_FIFO)

The account must close trades in the order they opened (first in, first out). Close the oldest trade on that symbol first.

150ERR_TRADE_PROHIBITED_BY_FIFO
After a fixSafe to retry?
NoCould it have executed?

What it means

You see this code in GetLastError() in MQL4, after a trade function fails on the server side.

FIFO accounts require the oldest trade on a symbol to close before newer ones. Closing a newer trade first is refused with 150.

The rule is common on accounts regulated in the United States.

Common causes

  • Closing a newer trade while an older one on the same symbol is open.
  • Strategies that manage each trade on its own.

How to fix it

  • Sort open trades on the symbol by OrderOpenTime() and close the oldest first.

Example in MQL4:

int OldestTicket(string sym)
{
   int best = -1; datetime t = 0;
   for(int i = OrdersTotal() - 1; i >= 0; i--)
      if(OrderSelect(i, SELECT_BY_POS) && OrderSymbol() == sym && OrderType() <= OP_SELL)
         if(best < 0 || OrderOpenTime() < t) { best = OrderTicket(); t = OrderOpenTime(); }
   return best;
}

Is it safe to retry?

After closing in the right order.

Could the order have executed?

No. The close was refused because an older position on the symbol must close first.

How Tickwire handles it

Tickwire treats it like MT5 10045, and the MT4 code stays in the message. See trade results.

All MetaTrader error codes

One API for MT4 and MT5

Clear trade outcomes, idempotent orders and an audit log. Read the error reference or the quickstart.