MT5 error 10036: Position already closed (TRADE_RETCODE_POSITION_CLOSED)
The position you named is already closed, perhaps by its stop or by an earlier request. There is nothing left to close.
What it means
You see this code in the retcode of a trade result, from OrderSend() in MQL5 or order_send() in Python.
The position identifier in the request belongs to a position that no longer exists. It was closed before your request arrived.
If your goal was to be flat, you already are.
Common causes
- Stop loss or take profit hit just before your close.
- A retry of a close that worked the first time.
- Another program or a person closed it.
- A stop out by the broker.
How to fix it
- Treat it as done if you wanted the position closed.
- Look up the closing deal in history if you need the price and profit.
Example in Python:
import MetaTrader5 as mt5
r = mt5.order_send(close_request)
if r is not None and r.retcode == mt5.TRADE_RETCODE_POSITION_CLOSED:
deals = mt5.history_deals_get(position=close_request["position"]) or ()
for d in deals:
print(d.time, d.entry, d.volume, d.price, d.profit) Is it safe to retry?
No. The position is gone.
Could the order have executed?
Not a trade. Your close didn't execute, but the position was already closed.
How Tickwire handles it
Tickwire reports this as no_change, which counts as success. A second close of the same position is distinguishable from the first one. See outcomes.
Related codes
One API for MT4 and MT5
Clear trade outcomes, idempotent orders and an audit log. Read the error reference or the quickstart.