MT5 error 10046: Hedging prohibited (TRADE_RETCODE_HEDGE_PROHIBITED)

The account doesn't allow opposite positions on one symbol. A sell against an open buy (or the reverse) was refused.

10046TRADE_RETCODE_HEDGE_PROHIBITED
After a fixSafe to retry?
NoCould it have executed?

What it means

You see this code in the retcode of a trade result, from OrderSend() in MQL5 or order_send() in Python.

On a hedging account the broker can still forbid holding a buy and a sell on the same symbol at once. 10046 means your order would create that.

Pending orders in the opposite direction are refused too.

Common causes

  • A strategy that opens a sell while a buy is open, instead of closing the buy.
  • Two programs trading the same symbol in different directions.

How to fix it

  • Close or reduce the existing position instead of opening the opposite one.
  • Check open positions on the symbol before sending.

Example in Python:

import MetaTrader5 as mt5

open_buys = [p for p in mt5.positions_get(symbol="EURUSD") or ()
             if p.type == mt5.POSITION_TYPE_BUY]
if open_buys:
    print("close the buy instead of opening a sell")

Is it safe to retry?

After you close the opposite position.

Could the order have executed?

No. The order was refused.

How Tickwire handles it

On MT5 accounts marginMode in account information tells you if the account is hedging or netting. See hedging and netting.

MT4 error 149 comes back as 10046.

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.