MT5 return code 10009: Request completed (TRADE_RETCODE_DONE)
MT5 return code 10009 means the trade request completed. The deal, close or change happened; read the result and don't send it again.
What it means
You see this code in the retcode of a trade result, from OrderSend() in MQL5 or order_send() in Python.
10009 is the normal success answer. A market order filled, a position closed, or a modification of stops or a pending order took effect.
The result carries the details: deal and order tickets, the filled volume and the price. Those are the facts to store, not the request you sent.
Common causes
- A successful market order, close, modify or delete.
How to fix it
- Nothing to fix. Save
result.deal,result.order,result.volumeandresult.price. - Compare
result.volumewith what you asked for. A full fill answers 10009; a partial one answers 10010. - For a position on a hedging account, read the position id from the deal if you need to close it later.
Example in Python:
import MetaTrader5 as mt5
r = mt5.order_send(request)
if r is None:
print("call failed:", mt5.last_error())
elif r.retcode == mt5.TRADE_RETCODE_DONE:
print(f"filled {r.volume} at {r.price}, deal {r.deal}, order {r.order}")
else:
print("not done:", r.retcode, r.comment) Is it safe to retry?
No. The request is done. Repeating it repeats the trade.
Could the order have executed?
Yes. This is the confirmed fill or change.
How Tickwire handles it
Tickwire returns numericCode 10009 and stringCode TRADE_RETCODE_DONE with outcome applied. A retry with the same Idempotency-Key returns this result with the Idempotent-Replayed: true header and sends nothing.
MT4 has no return codes. A successful MT4 trade comes back as 10009 too.
Related codes
- MT5 return code 10008: Order placed (TRADE_RETCODE_PLACED)
- MT5 return code 10010: Only part of the request was completed (TRADE_RETCODE_DONE_PARTIAL)
- MT5 error 10025: No changes in request (TRADE_RETCODE_NO_CHANGES)
Related MT5 Python functions
One API for MT4 and MT5
Clear trade outcomes, idempotent orders and an audit log. Read the error reference or the quickstart.