Quick Answer
Trade return code 10024 (TRADE_RETCODE_TOO_MANY_REQUESTS, "Too frequent requests") means that your terminal sent trade requests faster than the trade server accepts them. The request itself may be perfectly valid. The server refuses it because of how often you ask, not because of what you ask.
The limit is set by the broker's server and is not published in the terminal, so there is no number to quote. What you control is your own EA: decide when a request may be sent (once per signal, once per bar), keep a minimum gap between requests, send a queue one item at a time, and back off after a refusal. The sections below show these four pieces, and an EA that prints how a request gate decides, without sending anything.
From the author: I build and convert Expert Advisors. 10024 is almost always a symptom of logic that runs on every tick: a trailing stop that modifies each time the price moves, a retry loop after a failure, or a grid that opens ten orders in one
forloop. The fix is in the logic, not in the broker.
Key Facts
| What you see | Usual cause | Fix |
|---|---|---|
| 10024 after a burst of orders | A loop sends many requests at once | Queue them and send one at a time |
| 10024 on modify requests | A trailing stop modifies on every tick | Modify only when the stop really changes |
| 10024 after another failure | A retry loop with no wait | Back off: wait longer after each failure |
| 10024 with several EAs on one account | All EAs share the same limit | Space the requests, or reduce the number of EAs |
| 10024 only in a fast market | More ticks, more requests | Gate by bar or by time, not by tick |
| 10024 in a timer EA | EventSetTimer period is very short | Use a longer timer period |
What the Error Looks Like
With CTrade, a refused request makes the call return false, and the code is in the result:
if(!trade.Buy(lots, _Symbol, 0.0, sl, tp, "bot"))
{
PrintFormat("Order failed. Retcode %u: %s",
trade.ResultRetcode(), trade.ResultRetcodeDescription());
}
With OrderSend, the code is in MqlTradeResult.retcode. If 10024 shows up in a burst, look at what happened just before: the log lines before the first 10024 usually show the loop or the handler that sent too much. The list of all codes is in MQL5 trade return codes.
Cause 1: Sending on Every Tick
OnTick() runs for every price change. A rule such as "if the condition is true, send an order" sends again on the next tick if the condition is still true, and so on. Gate the logic by bar (see barstate.isnew in MQL5) or by signal (a flag that is set when an order was sent for this signal):
datetime g_lastBar = 0;
void OnTick()
{
datetime bar = iTime(_Symbol, _Period, 0);
if(bar == g_lastBar)
return; // already handled this bar
g_lastBar = bar;
// signal logic and at most one request here
}
Set g_lastBar after your data reads succeeded, so that a bar can be retried if the indicators were not ready.
Cause 2: A Loop That Sends Many Requests
A grid or a "close all" routine that sends ten requests inside one loop sends them in a fraction of a second. Put the work in a queue and send one item per tick or per timer event:
struct PendingJob
{
ulong ticket; // position to close, for example
};
PendingJob g_queue[];
void Enqueue(ulong ticket)
{
int n = ArraySize(g_queue);
ArrayResize(g_queue, n + 1);
g_queue[n].ticket = ticket;
}
and in OnTimer() (set with EventSetTimer(1)) take the first item, send it, and remove it only after a success. One request per second is easy to reason about, and you can raise the rate later if the broker allows it.
Cause 3: A Modify on Every Tick
A trailing stop that sends a modify whenever the price moves sends many requests with the same or almost the same stop. Compare the wanted stop with the current one before you send, and move the stop only when the difference is at least one price step. A modify that changes nothing is refused with its own return code (10025, "No changes in request"), and the habit that avoids it also avoids 10024. See the trailing stop EA for the structure of a trailing rule, and invalid stops error 10016 for the distance rule.
Cause 4: A Retry Loop With No Wait
A retry that runs again at once after every failure is a burst by design. Keep a time stamp for the next allowed attempt and make the wait longer after each failure:
datetime g_nextTry = 0;
int g_failCount = 0;
bool MayTryNow() { return TimeCurrent() >= g_nextTry; }
void OnRequestRefused()
{
g_failCount++;
int wait = (g_failCount == 1) ? 5 : (g_failCount == 2 ? 30 : 120);
g_nextTry = TimeCurrent() + wait;
}
void OnRequestOk()
{
g_failCount = 0;
g_nextTry = 0;
}
Use TimeCurrent() and not Sleep(): Sleep() blocks the EA, and the Strategy Tester has its own clock.
A Request Gate: A Minimum Gap Between Requests
One small helper that every request goes through gives you a single place to control the rate:
class RequestGate
{
datetime m_last;
int m_minGap; // seconds
public:
RequestGate(int minGapSeconds) { m_last = 0; m_minGap = minGapSeconds; }
bool Allow(datetime now)
{
if(m_last != 0 && now - m_last < m_minGap)
return false;
m_last = now;
return true;
}
};
Ask gate.Allow(TimeCurrent()) before each trade.Buy, Sell, PositionModify or PositionClose. If it returns false, skip the request and try on the next tick or the next timer event. Close and protective requests (a stop loss modify, a close of a losing position) matter more than new entries, so decide on purpose which requests may wait and which may not.
A Full EA That Prints the Gate Decisions
This EA does not place trades. It simulates a series of request times and prints which requests the gate would allow. Run it on a demo account:
#property strict
class RequestGate
{
datetime m_last;
int m_minGap;
public:
RequestGate(int minGapSeconds) { m_last = 0; m_minGap = minGapSeconds; }
bool Allow(datetime now)
{
if(m_last != 0 && now - m_last < m_minGap)
return false;
m_last = now;
return true;
}
};
int OnInit()
{
RequestGate gate(2); // at least 2 seconds between requests
int offsets[] = { 0, 0, 1, 2, 3, 3, 5, 5, 10, 11 }; // seconds after the start
datetime start = 1700000000; // a fixed example time
for(int i = 0; i < ArraySize(offsets); i++)
{
bool ok = gate.Allow(start + offsets[i]);
PrintFormat("t=+%2ds -> %s", offsets[i], ok ? "send" : "skip");
}
return INIT_SUCCEEDED;
}
With a gap of 2 seconds, the output should be: send, skip, skip, send, skip, skip, send, skip, send, skip. If it differs, check the gap logic.
Similar Return Codes
| Code | Name | What it means |
|---|---|---|
| 10024 | TRADE_RETCODE_TOO_MANY_REQUESTS | Requests are sent too often |
| 10006 | TRADE_RETCODE_REJECT | The request was refused, no reason named |
| 10025 | TRADE_RETCODE_NO_CHANGES | The request changes nothing |
| 10021 | TRADE_RETCODE_PRICE_OFF | There are no quotes to process the request |
| 10031 | TRADE_RETCODE_CONNECTION | No connection with the trade server |
Checklist: What to Check When You See 10024
- Read the log before the first 10024. Which handler sent the requests?
- Gate by bar or by signal, not by tick.
- Queue bulk work and send one item per timer event.
- Compare before you modify, and modify only when the stop changes.
- Back off after a refusal, and stop after a few attempts.
- Route every request through one gate with a minimum gap.
- Count requests per minute in the log, and compare with the broker's rules.
- Test on a demo account before the EA trades with real money.
Common Mistakes
- Sending in
OnTickwithout a bar or signal check. - Closing ten positions in one loop.
- Modifying a stop on every price change.
- Retrying at once after a failure.
- Using
Sleep()to slow down an EA that must keep handling events. - Running several EAs on one account without thinking about their combined rate.
FAQ
Related Guides
- MQL5 trade return codes: what each return code means and how to react.
- MQL5 trailing stop EA: move a stop without breaking the minimum distance.
- MQL5 invalid stops error 10016: the matching error for stop loss and take profit.
- MQL5 invalid request error 10013: a request with a missing or wrong field.
- MQL5 autotrading disabled error 10027: the terminal, EA or account switch that blocks trading.
- MQL5 invalid price error 10015: a price that is stale, on the wrong side or not rounded to the tick size.
- MQL5 market closed error 10018: an order sent outside the trading session.
- MQL5 daily loss limit: stop trading when the day goes wrong.
- Pine Script barstate.isnew in MQL5: run logic once per bar.
- What to check in a trading bot before going live: a pre-live checklist for stops, lot size, spread and trade results.
- MQL5 no quotes (10021) and no connection (10031): check the link and the tick before you send.
- MQL5 request rejected error 10006: the server refused the request without naming a reason.
- MQL5 no changes error 10025: a modify that sends the same stop or take profit again.
Fix Compile Errors Without Guessing
If an Expert Advisor does not compile, or you want a second look at its order and risk logic, paste the code into the CodeFlowOS Error Fixer. It suggests a minimal fix, explains each error and shows what changed. A fix uses 1 credit, with up to 3 attempts included, and the compiler check is optional. Outputs are not guaranteed, and code that compiles can still have wrong trading logic, so always review the result. The Code Review is free during the early-bird period and checks an EA for common mistakes such as a fixed lot size or a missing stop loss. CodeFlowOS also converts strategies between Pine Script, MQL5 and cTrader C#: try the converter page.
This article is educational. It does not describe trading performance and is not financial advice. Always compile and test code in MetaEditor and the Strategy Tester before using it on a live account.