What it means
The broker didn't accept the price in your request and answered with new prices instead. Nothing was opened. Requotes belong to Instant Execution: the terminal sends the price you saw, and the broker either fills at that price or requotes. On Market Execution symbols the broker picks the price itself, so there are no requotes, only slippage.
Usual causes
- The price moved between the moment the EA read it and the moment the broker processed the request, by more than the allowed deviation.
- A deviation of 0 or very small.
deviation(orSetDeviationInPoints()with CTrade) is the maximum distance from your price, in points, that you accept. - A stale price. A price saved on the last bar or earlier in a long calculation, instead of read just before sending.
- Fast markets. News releases and session opens move prices faster than the request travels.
Two neighbours: 10020 (TRADE_RETCODE_PRICE_CHANGED, "Prices changed") and 10021 (TRADE_RETCODE_PRICE_OFF, "There are no quotes to process the request").
How to detect it
result.retcode(ortrade.ResultRetcode()) is10004, andresult.bid/result.askhold the prices the broker offered. CTrade prints them in brackets:[requote (bid/ask)].SymbolInfoInteger(_Symbol, SYMBOL_TRADE_EXEMODE)tells you whether the symbol uses Instant, Request, Market or Exchange execution.
Broken code
This EA compiles. On an Instant Execution symbol it asks for an old price with zero tolerance, which the broker requotes whenever the market has moved.
#include <Trade/Trade.mqh>
CTrade trade;
double signalPrice = 0.0;
void OnTick()
{
// The price is saved once per bar and reused later
static datetime lastBar = 0;
datetime bar = iTime(_Symbol, PERIOD_CURRENT, 0);
if(bar != lastBar)
{
lastBar = bar;
signalPrice = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
}
if(PositionSelect(_Symbol))
return;
trade.SetDeviationInPoints(0); // no price movement accepted at all
trade.Buy(0.10, _Symbol, signalPrice); // a price that may be minutes old
}Fixed code
The same program with the check that prevents the error. It compiles in MetaEditor with 0 errors and 0 warnings.
#include <Trade/Trade.mqh>
input int InpDeviationPts = 10; // Accepted price deviation, points
input int InpMaxAttempts = 3; // Attempts per signal
CTrade trade;
int attemptsLeft = 0;
int OnInit()
{
trade.SetDeviationInPoints(InpDeviationPts);
return INIT_SUCCEEDED;
}
void OnTick()
{
static datetime lastBar = 0;
datetime bar = iTime(_Symbol, PERIOD_CURRENT, 0);
if(bar != lastBar)
{
lastBar = bar;
attemptsLeft = InpMaxAttempts; // a new signal gets a few attempts
}
if(attemptsLeft <= 0 || PositionSelect(_Symbol))
return;
MqlTick tick;
if(!SymbolInfoTick(_Symbol, tick))
return;
attemptsLeft--;
// Fresh price, read just before sending
if(trade.Buy(0.10, _Symbol, tick.ask))
{
attemptsLeft = 0;
return;
}
uint rc = trade.ResultRetcode();
if(rc == TRADE_RETCODE_REQUOTE || rc == TRADE_RETCODE_PRICE_CHANGED)
PrintFormat("Requote, %d attempt(s) left on the next ticks", attemptsLeft);
else
{
PrintFormat("Buy failed: retcode %u (%s)", rc, trade.ResultRetcodeDescription());
attemptsLeft = 0; // other errors won't fix themselves
}
}Why the fix works
The price is read with SymbolInfoTick() right before the request, and the deviation tells the broker how far from it you're willing to be filled. If the broker still requotes, the EA tries again on the next ticks with a fresh price, a limited number of times, and stops at once on any other error. A retry loop without a limit, or a retry on every error, is how EAs end up spamming the server.
The deviation is a trade-off you choose: a larger one means fewer requotes and possibly a worse price.
Questions
Can I avoid requotes completely in MT5?
Not on an Instant Execution symbol: the broker can always refuse your price. A sensible deviation makes them rarer. On Market Execution symbols there are no requotes because you accept the broker's price in advance, which can mean slippage instead.
What deviation should I set?
There's no universal value. It's in points, so the same number means different things on a 5-digit forex pair and on gold. Choose the worst price difference you'd accept for that symbol and trade size.
Is MT5 error 10004 the same as MT4 error 138?
Yes. MQL4's error 138 (ERR_REQUOTE) is trade server return code 10004 in MQL5.
The programs on this page are minimal examples written to show the error and its fix, not trading systems. Some of them send orders when they run: try them on a demo account. Trading involves substantial risk of loss and is not suitable for every investor. Edgoro is a software tool, not a broker or financial adviser: nothing it produces is investment advice, and past or backtested performance does not guarantee future results.