MT5 · code and request checks
MT5 error 10004: a requote is not a reason to retry forever
Your EA needs a stop condition after a requote. My policy example compiled with 0 errors; it sends no orders and proves no broker-side repair.

Arnold Holm · 2026-10-23
What the error means
A trader asked why a USDJPY buy request returned 10004 when the requested price and the server ask differed by only 0.001. That price difference alone does not establish the cause. The official MT5 server-return table names 10004 as TRADE_RETCODE_REQUOTE. Keep that server result alongside the exact request and quote instead of treating every rejected request as the same error. A requote does not mean a position was opened. The table gives other codes for an order placed, a request completed and a request partly completed. The next decision depends on the actual result and account state. Do not let a generic retry branch treat those outcomes as interchangeable. I separate receiving a requote from deciding whether an entry is still worth considering. A new quote can make an old signal stale or put the spread and price outside its limits. A loop that keeps resending until something succeeds can enter long after the original conditions disappeared. The helper below only answers a local policy question: may this requote be reconsidered under the caller's stated limits? It rejects other return codes, an invalid signal, an exhausted attempt budget, an old quote, an invalid or excessive spread, and a price outside the allowed limit. A true result is permission to inspect the situation again. It is not permission to submit a trade blindly. The caller must supply current values and still check its order and position state.
Three code paths to check
1. The request and its server result were not preserved together.
Keep the requested price, bid, ask, execution mode, deviation, timestamps and full MqlTradeResult. A screenshot of one price difference cannot explain the whole request.
2. The retry branch ignores the original entry conditions.
Recheck the signal, quote age, spread and price limit before considering another request. Stop once the retry budget is used.
3. Several trade outcomes share one generic error branch.
Keep a requote separate from placed, completed and partly completed outcomes. Check orders and positions before any new submission to avoid duplicate intent.
A bounded local policy, with no order submission
I compiled RequotePolicy.mq5 with native MetaEditor on 23 October 2026. The compiler reported 0 errors and 0 warnings. The image renders that actual compiler result. Its OnStart only prints a label; it does not call this helper. I did not execute the script. The limits are explicit inputs, not recommended trading settings. Quote age is supplied in milliseconds and spread in points. The caller is responsible for measuring them correctly and keeping attempt counts current. This example does not obtain quotes, change deviation or filling mode, wait for a new event, inspect positions, or retry an order.
bool MayReconsider(const uint retcode,const bool signal_valid,
const int attempts,const int max_attempts,
const long quote_age_ms,const long max_age_ms,
const double spread_points,const double max_spread_points,
const bool inside_price_limit)
{
if(retcode!=TRADE_RETCODE_REQUOTE || !signal_valid) return false;
if(max_attempts<=0 || attempts<0 || attempts>=max_attempts) return false;
if(max_age_ms<0 || quote_age_ms<0 || quote_age_ms>max_age_ms) return false;
if(!MathIsValidNumber(spread_points) || !MathIsValidNumber(max_spread_points)) return false;
if(spread_points<0 || max_spread_points<0 || spread_points>max_spread_points) return false;
return inside_price_limit;
}Compile-only proof. No runtime branch tests, reproduced server 10004, broker request, automatic retry or successful trade.
How you know it is fixed
Keep the failed request intact
Save the full request, result.retcode and result.comment, requested price, observed bid/ask, symbol execution mode and timestamp. Do not overwrite the first failure with the result of a later attempt.
Test refusal before any order path
On a separate demo test, cover a false signal, exhausted attempts, old quote, excessive spread and a price outside the limit. None may reach an order-send branch.
Your five-minute source check
Find the branch handling 10004. Trace its maximum attempts, its signal-validity check and the exact condition that prevents a new request. If one is missing, an automatic retry can outlive the original entry.
Your own source
Find the next line to check
Start with the free EA-Check. Your code stays in your browser. It highlights patterns with line numbers; it does not prove the broker accepts an order.
Want one small change shown on your own case?
DEMO0: send the problem and try a free compiled demo first. R49: one authorised, reproducible MT4/MT5 defect in readable source up to 500 lines, with three agreed cases. 49 USD fixed. Delivery within 48 hours after source review and funding. The exact case is agreed before funded work.
Send the expected and actual behaviourRelated checks
Common questions
Does increasing deviation always fix error 10004?
No universal repair follows from this code alone. Preserve the actual request, execution mode and server result before changing a setting.
Does a true helper result mean I should send an order?
No. It only passes this local policy. The caller still needs current inputs, order and position checks, and a separate submission decision.
Was a broker requote reproduced and fixed in this proof?
No. Only compilation is evidenced. The script was not executed and no broker request was made.
Sources and limits
These public questions explain the error; use your own EA log to check whether the same cause applies.