MT5 error 4755: Deal not found (ERR_TRADE_DEAL_NOT_FOUND)
The deal ticket isn't in the history the terminal has loaded. Call HistorySelect for the right time range first.
What it means
You see this code in GetLastError() in MQL5, after a function fails.
Deals live in history, and MQL5 only searches the part of history you have loaded. If the deal is outside that range, or the ticket is wrong, the lookup fails with 4755.
The deal usually exists. It just isn't in the selected range.
Common causes
- No
HistorySelect()call before reading deals. - A range built in local time or UTC that misses the deal in server time.
- An order ticket used where a deal ticket is needed.
How to fix it
- Call
HistorySelect(from, to)with a wide range, orHistoryDealSelect(ticket)for one deal. - Build the range from server time, with a margin either side.
Example in MQL5:
datetime to = TimeCurrent() + 86400; // server time, plus a margin
datetime from = to - 30 * 86400;
if(HistorySelect(from, to) && HistoryDealSelect(deal_ticket))
Print("profit ", HistoryDealGetDouble(deal_ticket, DEAL_PROFIT));
else
Print("deal not found, error ", GetLastError()); Is it safe to retry?
Yes, after selecting the right history range.
Could the order have executed?
Not a trade code. It is a lookup.
How Tickwire handles it
History deals and orders are in the API with ranges you set. Broker server time is measured, never assumed to be UTC. See time zones.
Related codes
- MT5 error 4401: Requested history not found (ERR_HISTORY_NOT_FOUND)
- MT5 error 4753: Position not found (ERR_TRADE_POSITION_NOT_FOUND)
- MT5 error 4754: Order not found (ERR_TRADE_ORDER_NOT_FOUND)
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.