MT4 error 128: Trade timeout (ERR_TRADE_TIMEOUT)
The terminal stopped waiting for the broker's answer. The order may still have executed, so check before you send it again.
What it means
You see this code in GetLastError() in MQL4, after a trade function fails on the server side.
MT4 gave up waiting for the trade server. The broker may have received the request and filled it after the terminal stopped waiting.
Resending blindly after 128 is a classic way to open the same trade twice.
Common causes
- A slow or overloaded trade server.
- Network delay between the terminal and the broker.
- A request sent during a reconnect.
How to fix it
- Wait a moment, then look for the order in open orders and history.
- Resend only if there is no trace of it.
- Tag every order with a magic number and a unique comment so it can be found.
Example in MQL4:
// After an unclear answer: did the order open anyway?
int FindMine(const string sym, const int magic, const string tag)
{
for(int i = OrdersTotal() - 1; i >= 0; i--)
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)
&& OrderSymbol() == sym && OrderMagicNumber() == magic
&& OrderComment() == tag)
return OrderTicket();
return -1;
}
int ticket = OrderSend(Symbol(), OP_BUY, 0.10, Ask, 3, 0, 0, "job-4711", 4711);
if(ticket < 0)
{
int err = GetLastError();
if(err == ERR_TRADE_TIMEOUT)
{
Sleep(2000);
RefreshRates();
int found = FindMine(Symbol(), 4711, "job-4711");
Print(found > 0 ? "It opened: ticket " + IntegerToString(found) : "No trace yet; check history before resending");
}
} Is it safe to retry?
Only after checking. This is the MT4 code most likely to cause a duplicate.
Could the order have executed?
Maybe. The broker may have filled the order after the terminal stopped waiting. Only open orders and history can tell you.
How Tickwire handles it
Tickwire treats it like MT5 10031, and the MT4 code stays in the message. It never sends new exposure again; it looks for the effect and reports applied, rejected or unknown. See idempotency.
Related codes
One API for MT4 and MT5
Clear trade outcomes, idempotent orders and an audit log. Read the error reference or the quickstart.