Quick Answer
Trade return code 10006 (TRADE_RETCODE_REJECT) means that the server received your request and refused it. Unlike the specific codes (a wrong volume gives 10014, a wrong price 10015, wrong stops 10016, not enough money 10019), 10006 does not name the reason. It is the answer you get when the broker's trade server declines a request for a reason that has no code of its own, or one that the broker chooses not to describe. The rules behind it depend on the broker and the account.
So the work is not to fix "10006" but to rule out the known causes one by one: check the request with OrderCheck, check the symbol and the session, check how often you send requests, and then decide whether to try again. The sections below give a short order of checks, a retry rule that does not hammer the server, and an EA that prints the advice for several return codes without sending an order.
From the author: I build and convert Expert Advisors. 10006 is the code that looks the same in the log for very different problems, and an EA that retries it in a tight loop makes things worse: more requests, more rejections, and sometimes a block from the broker. A bot should treat it as "stop, look, wait", not as "try again at once".
Key Facts
| What you see | Usual cause | What to do |
|---|---|---|
| 10006 right after a request that looks fine | The server declined it for a reason it does not name | Run OrderCheck, check symbol, session and account rights |
| 10006 in bursts | Too many requests in a short time | Add a cool-down between requests |
| 10006 only for one symbol | A symbol rule (trade mode, session, size limit) | Read the symbol specification, check the trade mode |
| 10006 only at some times of the day | Session break, rollover or news restrictions | Log the time, check the trade sessions |
| 10006 on one account only | An account rule (account type, restrictions) | Ask the broker; compare with a second account |
| 10006 that goes away after a moment | A temporary state on the server | Retry a small number of times with a delay |
What the Error Looks Like
With CTrade, a refused order 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. Log the code and the symbol, the volume, the price and the time, because 10006 usually needs context to be understood. The full list of codes is in MQL5 trade return codes.
Step 1: Rule Out the Codes With a Name
Many problems that look like a plain rejection have their own code, and you see it when you test the request first. OrderCheck runs checks on the request without sending it, and returns a check result with a return code and a comment:
bool CheckRequest(MqlTradeRequest &request)
{
MqlTradeCheckResult check;
ZeroMemory(check);
bool ok = OrderCheck(request, check);
PrintFormat("OrderCheck ok=%s retcode=%u comment=%s",
ok ? "true" : "false", check.retcode, check.comment);
return ok;
}
If the check names a problem, fix that one: invalid volume (10014), invalid price (10015), invalid stops (10016), not enough money (10019), market closed (10018) or unsupported filling mode. OrderCheck only checks what the terminal can check; the server has the last word, so a request that passes the check can still be refused.
Step 2: Check the Symbol and the Session
Look at the specification of the symbol in the terminal: the trade mode (full access, close only, disabled), the trading sessions and the volume limits. A symbol in "close only" mode accepts orders that reduce a position and refuses the others. Read the values in code too, so the log shows them next to the code:
long tradeMode = SymbolInfoInteger(_Symbol, SYMBOL_TRADE_MODE);
double volMin = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN);
double volMax = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MAX);
PrintFormat("%s tradeMode=%d volMin=%.2f volMax=%.2f", _Symbol, (int)tradeMode, volMin, volMax);
Step 3: Check How Often You Send
An EA that sends a request on every tick, or in a loop after a failure, can be refused because of the frequency alone. The MetaEditor help has a specific code for this, 10024 (TRADE_RETCODE_TOO_MANY_REQUESTS, "Too frequent requests"), but some servers may answer with a plain rejection instead. The fix is the same: send less often. Decide in your logic when an order may be sent (once per bar, once per signal), and keep a cool-down after any failure.
Step 4: Check the Account
An account can have rules that the terminal does not show in the request: the account type, a restriction on opening positions, a limit on the number of orders or positions, or a mode in which only closing is allowed. If one account gives 10006 and another does not, with the same EA, the cause is on the account side, and the broker's support can tell you the exact rule. When you write to support, give the time, the symbol, the volume and the return code.
Step 5: Retry With a Cool-Down, Not in a Loop
Some rejections are temporary. A retry rule that is safe for the account:
- Do not retry in a loop inside one tick. Keep a time stamp for the next allowed attempt.
- Wait longer after each failure (for example 5 seconds, then 30, then 120).
- Stop after a small number of attempts and log the final failure, with all the values.
- Re-read the price and re-check the conditions before each attempt. A signal from a minute ago may no longer be valid.
- Never retry the codes that mean "your request is wrong" (invalid volume, invalid stops). The same request fails again.
datetime g_nextTry = 0;
int g_failCount = 0;
bool MayTryNow()
{
return TimeCurrent() >= g_nextTry;
}
void OnOrderFailed(uint retcode)
{
g_failCount++;
int waitSeconds = (g_failCount == 1) ? 5 : (g_failCount == 2 ? 30 : 120);
g_nextTry = TimeCurrent() + waitSeconds;
PrintFormat("Order failed, retcode %u. Failure %d, next try in %d s", retcode, g_failCount, waitSeconds);
}
void OnOrderOk()
{
g_failCount = 0;
g_nextTry = 0;
}
Use TimeCurrent() for the wait and not Sleep(): Sleep() blocks the EA, and in the Strategy Tester the time moves with the test, not with your wall clock.
A Full EA That Prints the Advice
This EA does not place trades. It takes a list of return codes, prints a short advice for each one, and prints the symbol data once. Run it on a demo account:
#property strict
string Advice(uint retcode)
{
switch((int)retcode)
{
case TRADE_RETCODE_REJECT: return "Rejected: run OrderCheck, check symbol, session, frequency, account; retry with a cool-down";
case TRADE_RETCODE_REQUOTE: return "Requote: read a fresh price, try again once";
case TRADE_RETCODE_TIMEOUT: return "Timeout: check the state of the order before you send again";
case TRADE_RETCODE_INVALID: return "Invalid request: fix the fields, do not retry";
case TRADE_RETCODE_INVALID_VOLUME: return "Invalid volume: fix the lot size, do not retry";
case TRADE_RETCODE_INVALID_STOPS: return "Invalid stops: fix the distance, do not retry";
case TRADE_RETCODE_NO_MONEY: return "Not enough money: reduce the volume, do not retry";
case TRADE_RETCODE_MARKET_CLOSED: return "Market closed: wait for the session";
default: return "Check the code in the help and the trade log";
}
}
int OnInit()
{
uint codes[] = { TRADE_RETCODE_REJECT, TRADE_RETCODE_REQUOTE, TRADE_RETCODE_TIMEOUT,
TRADE_RETCODE_INVALID, TRADE_RETCODE_INVALID_VOLUME, TRADE_RETCODE_INVALID_STOPS,
TRADE_RETCODE_NO_MONEY, TRADE_RETCODE_MARKET_CLOSED };
for(int i = 0; i < ArraySize(codes); i++)
PrintFormat("%u -> %s", codes[i], Advice(codes[i]));
long tradeMode = SymbolInfoInteger(_Symbol, SYMBOL_TRADE_MODE);
double volMin = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN);
double volMax = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MAX);
PrintFormat("%s tradeMode=%d volMin=%.2f volMax=%.2f", _Symbol, (int)tradeMode, volMin, volMax);
return INIT_SUCCEEDED;
}
The EA is meant to be read next to the list of return codes in the MetaEditor help. Check that every constant exists in your build.
Similar Return Codes
| Code | Name | What it means |
|---|---|---|
| 10004 | TRADE_RETCODE_REQUOTE | The price changed; read a fresh price |
| 10006 | TRADE_RETCODE_REJECT | The request was refused, no reason named |
| 10024 | TRADE_RETCODE_TOO_MANY_REQUESTS | Requests are sent too often |
| 10012 | TRADE_RETCODE_TIMEOUT | The request timed out; check before you resend |
| 10013 | TRADE_RETCODE_INVALID | The request is invalid as a whole |
| 10014 | TRADE_RETCODE_INVALID_VOLUME | The volume does not match the symbol rules |
| 10016 | TRADE_RETCODE_INVALID_STOPS | The stops are too close or on the wrong side |
| 10019 | TRADE_RETCODE_NO_MONEY | Not enough free margin |
Checklist: What to Check When You See 10006
- Log the code with the context: symbol, volume, price, stops, time.
- Run
OrderCheckon the same request and read its code and comment. - Read the symbol: trade mode, sessions, volume limits.
- Count your requests: one per signal, not one per tick.
- Compare accounts: the same EA on another account tells you if it is an account rule.
- Retry with a cool-down, a small number of times, and re-check the signal each time.
- Do not retry the codes that mean "your request is wrong".
- Contact the broker with the time, symbol, volume and code if it keeps happening.
- Test on a demo account before the EA trades with real money.
Common Mistakes
- Retrying in a loop inside one tick.
- Logging only the code, without the symbol, the volume and the time.
- Treating 10006 as a bug in the EA when it is an account or symbol rule.
- Sending on every tick and being refused for the frequency.
- Using
Sleep()for the wait in an EA that must keep handling events. - Ignoring the check that
OrderCheckgives for free.
FAQ
Related Guides
- MQL5 trade return codes: what each return code means and how to react.
- MQL5 invalid volume error 10014: a lot size that does not match the symbol rules.
- MQL5 invalid price error 10015: a price that is stale, on the wrong side or not rounded to the tick size.
- MQL5 invalid stops error 10016: the matching error for stop loss and take profit.
- MQL5 market closed error 10018: an order sent outside the trading session.
- MQL5 not enough money error 10019: not enough free margin for the order.
- MQL5 unsupported filling mode error: another order rejection with a clear fix.
- MQL5 daily loss limit: stop trading when the day goes wrong.
- MQL5 filter positions by magic number: find the position you want to change.
- What to check in a trading bot before going live: a pre-live checklist for stops, lot size, spread and trade results.
- MQL5 no changes error 10025: a modify that sends the same stop or take profit again.
- MQL5 OrderSend failed with error 4756: read the retcode behind 4756, then fix the request.
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.