Trade server return code
10024 TRADE_ RETCODE_ TOO_ MANY_ REQUESTS
Too frequent requests: the EA sends faster than the server allows
What it means
The server refused the request because the account is sending too many in a short time. Brokers protect their servers from EAs that flood them; repeated floods can lead to the account being restricted.
Common causes
- A trailing stop that sends a modification on every tick instead of in steps.
- A retry loop that resends a failed request immediately, again and again.
- Several EAs on the same account each managing the same positions.
A real scenario
A trailing stop moves the stop loss by one point on every tick. In a fast market that is several modifications a second, and the server starts answering 10024. Moving the stop only in steps of 50 points, and at most once a second, cut the requests to a few per minute with the same protection.
How to fix it
- Trail in steps: modify only when the new stop is a minimum distance better than the current one.
- Throttle: at most one modification per position per second, for example with
GetTickCount64(). - Never resend a failed request in a tight loop; wait for the next tick or bar.
Fixed MQL5 code
#include <Trade/Trade.mqh>
CTrade trade;
ulong g_lastModifyMs = 0;
bool MayModifyNow(const ulong minIntervalMs = 1000)
{
ulong now = GetTickCount64();
if(now - g_lastModifyMs < minIntervalMs)
return false;
g_lastModifyMs = now;
return true;
}
void TrailBuy(const ulong ticket, const double trailPoints, const double minStepPoints)
{
if(!PositionSelectByTicket(ticket))
return;
double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
double oldSl = PositionGetDouble(POSITION_SL);
double newSl = NormalizeDouble(bid - trailPoints * _Point, _Digits);
if(newSl - oldSl < minStepPoints * _Point) // move only in real steps, not on every tick
return;
if(!MayModifyNow())
return;
trade.PositionModify(ticket, newSl, PositionGetDouble(POSITION_TP));
}
A focused example for MetaTrader 5: adapt names, magic number and limits to your EA, and test it on a demo account first.
Related codes
- 10025No ChangesTRADE_RETCODE_NO_CHANGESNo changes: a modification that changes nothing
- 10006Request RejectedTRADE_RETCODE_REJECTRequest rejected by the trade server
Sources
Get your EA fixed
Still failing with 10024? Send us the EA and the journal lines: we find the cause in the code and fix it. Or check it yourself first with the EA Doctor.