MT4 error 149: Hedging is prohibited (ERR_TRADE_HEDGE_PROHIBITED)
The account doesn't allow a buy and a sell on the same symbol at once. Close the open trade instead of opening the opposite one.
What it means
You see this code in GetLastError() in MQL4, after a trade function fails on the server side.
The broker forbids hedging on this account. Opening an order opposite to an open one on the same symbol is refused with 149.
It is common on accounts regulated in the United States, which usually have FIFO rules too (error 150).
Common causes
- A strategy that opens a sell while a buy is open.
- A pending order that would trigger opposite to an open trade.
- Two programs trading the same symbol in different directions.
How to fix it
- Close the existing order instead of opening the opposite side.
- Check open orders on the symbol before sending.
- Keep one direction per symbol at a time in your code.
Example in MQL4:
bool HasOpen(string sym, int type)
{
for(int i = OrdersTotal() - 1; i >= 0; i--)
if(OrderSelect(i, SELECT_BY_POS) && OrderSymbol() == sym && OrderType() == type)
return true;
return false;
}
// Before a sell: if HasOpen(Symbol(), OP_BUY), close the buy instead. Is it safe to retry?
After closing the opposite order.
Could the order have executed?
No. The opposite order was refused, and the existing position is unchanged.
How Tickwire handles it
Tickwire treats it like MT5 10046, and the MT4 code stays in the message. See trade results.
Related codes
One API for MT4 and MT5
Clear trade outcomes, idempotent orders and an audit log. Read the error reference or the quickstart.