MT4 error 146: Trade context is busy (ERR_TRADE_CONTEXT_BUSY)
Another program in the same MT4 terminal was using the trade context. Nothing was sent; wait for it to free up and retry.
What it means
You see this code in GetLastError() in MQL4, after a trade function fails on the server side.
MT4 lets only one program trade at a time in a terminal. While one is sending, the trade context is busy, and the others get 146.
The request never left the terminal.
Common causes
- Several programs trading in the same terminal.
- A slow trade request from another chart.
- A manual trade in progress.
How to fix it
- Wait with
IsTradeContextBusy()before sending, with a time limit. - Run fewer trading programs per terminal.
Example in MQL4:
bool WaitForContext(int ms = 5000)
{
uint start = GetTickCount();
while(IsTradeContextBusy())
{
if(GetTickCount() - start > (uint)ms) return false;
Sleep(50);
}
RefreshRates();
return true;
} Is it safe to retry?
Yes. Nothing was sent, so a retry can't duplicate it.
Could the order have executed?
No. It never reached the broker.
How Tickwire handles it
Tickwire treats it like MT5 10024, and the MT4 code stays in the message.
Tickwire waits up to 5 s for the trade context before giving up. If it is still busy, you get 10024 with nothing sent, so a retry is safe. 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.