MT5 error 10007: Request canceled by trader (TRADE_RETCODE_CANCEL)

The request was canceled on the terminal side before it reached the market. Nothing was executed.

10007TRADE_RETCODE_CANCEL
YesSafe 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.

10007 says the trader side called the request off. In practice this happens when the terminal asks for a manual confirmation and the request is declined, or when the request is withdrawn before the server acts on it.

It is not a broker rejection. The server never filled anything.

Common causes

  • A confirmation dialog in the terminal was closed or declined.
  • A tool or plugin in the terminal that cancels requests it doesn't like.
  • The trade request was withdrawn while it waited to be processed.

How to fix it

  • Turn off manual confirmation for automated trading, so requests from code are not held for a click.
  • Check for other tools in the same terminal that might cancel requests.
  • Send again once you know the cancel was not on purpose.

Example in MQL5:

MqlTradeRequest req = {};
MqlTradeResult  res = {};
req.action   = TRADE_ACTION_DEAL;
req.symbol   = _Symbol;
req.volume   = 0.10;
req.type     = ORDER_TYPE_SELL;
req.price    = SymbolInfoDouble(_Symbol, SYMBOL_BID);
req.deviation = 20;

if(!OrderSend(req, res) && res.retcode == TRADE_RETCODE_CANCEL)
   Print("Canceled on the terminal side, nothing was sent to the market");

Is it safe to retry?

Yes, once you have checked that nobody canceled it on purpose. The first request did nothing.

Could the order have executed?

No. A canceled request never became an order.

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.