MT5 error 10041: Pending order activation rejected, order canceled (TRADE_RETCODE_REJECT_CANCEL)

Your pending order triggered, but the server rejected the fill and canceled the order. No position opened, and the order is gone.

10041TRADE_RETCODE_REJECT_CANCEL
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.

When a pending order's price is reached, the server tries to turn it into a position. 10041 means that step was refused, and the pending order was canceled instead.

You usually see it later, in the order history or a trade event, not as the answer to a request you just sent.

Common causes

  • Not enough free margin at the moment the order triggered.
  • A market gap or a trading rule that stopped the fill.
  • A broker check that runs only at activation.

How to fix it

  • Look the order up in history and check its state and comment.
  • Keep enough margin for pending orders that may trigger.
  • Place the order again if the setup still holds.

Example in Python:

import MetaTrader5 as mt5

for o in mt5.history_orders_get(ticket=ticket) or ():
    # ORDER_STATE_REJECTED or ORDER_STATE_CANCELED after a failed activation
    print(o.ticket, o.state, o.comment)

Is it safe to retry?

After a fix. You can place a new pending order once you know why the fill was refused.

Could the order have executed?

No. The order was canceled and no position opened.

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.