MQL5 Off-Quotes Error: Causes, Fixes, and EA Execution Best Practices

目次

1. What Is mql5 off-quotes?

[Conclusion]
In mql5, off-quotes is an execution error where an order fails because the current price (Bid/Ask) cannot be obtained at the time of order execution. It is mainly caused by delayed price updates, low liquidity, or communication issues.

MQL5 off-quotes error during OrderSend execution showing outdated price causing trade rejection, terminal log with TRADE_RETCODE_OFF_QUOTES, and execution flow from price retrieval to failed order
[Definition]
off-quotes means that an order is rejected because the trade server cannot return a valid executable price. It is a type of execution error.


1.1 Basic meaning of off-quotes

off-quotes occurs in an EA or manual order when “the order was sent, but no executable price exists.”
In other words, it is a state where the order conditions (price and allowed slippage) do not match the market price.

Key points:

  • The order itself is sent correctly
  • But it cannot be executed because the price does not match
  • As a result, an error is returned

It is especially likely under these conditions:

  • Rapid price movement (high volatility)
  • Spread widening
  • Communication latency

1.2 When it occurs

off-quotes mainly occurs during order execution.
Common cases include the following.

  • When OrderSend runs for a market order
  • When a limit order or stop order is triggered
  • When an EA sends consecutive orders at high speed
  • During sharp moves such as economic news releases

Example (MQL5):

MqlTradeRequest request;
MqlTradeResult result;

request.action   = TRADE_ACTION_DEAL;
request.symbol   = _Symbol;
request.volume   = 0.1;
request.type     = ORDER_TYPE_BUY;
request.price    = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
request.deviation= 5; // allowed slippage

OrderSend(request, result);

if(result.retcode == TRADE_RETCODE_OFF_QUOTES)
{
   Print("off-quotes error occurred");
}

Points:

  • Even if price is obtained, it may already be an outdated price
  • A small deviation value makes the error more likely

1.3 Difference from related errors

off-quotes is often confused with similar errors, so the differences should be clear.

off-quotes vs requote

  • off-quotes: the price itself cannot be obtained
  • requote: a price exists, but it has moved and is re-quoted

off-quotes vs no prices

  • off-quotes: the price update is not keeping up
  • no prices: market data itself does not exist, such as when the market is closed

off-quotes vs slippage

  • off-quotes: the order fails
  • slippage: the order succeeds, but at a different price

1.4 Points beginners often misunderstand

Common misunderstandings:

  • “It must be an EA bug”
    → In reality, market conditions or execution conditions are often the cause
  • “If my internet looks normal, there is no issue”
    → VPS location and server distance, meaning latency, can affect execution
  • “Spread has nothing to do with it”
    → When the spread widens, executable prices can disappear

1.5 Practical importance: why you need to understand it

off-quotes is not just an error. It is a problem directly connected to profitability and expected value.

Reasons:

  • No execution means missed trading opportunities
  • Unstable execution creates gaps between backtesting and live trading
  • PF (profit factor) can decline

In EA operation, these factors strongly affect performance:

  • Fill rate
  • Slippage control
  • Spread control

2. Causes of mql5 off-quotes (Why: understanding the mechanism)

[Conclusion]
off-quotes occurs when no executable price exists because the order price, market price, and communication timing are out of sync. The main causes are delayed price updates, strict slippage limits, and low liquidity.

[Definition]
The cause of off-quotes is a state where the trade server cannot find a price that matches the order conditions, so execution is not completed.


2.1 Cause 1: delayed price updates (tick not obtained)

An EA usually places orders based on the latest tick, or price update.
A problem occurs when there is a time lag between price retrieval and order submission.

Typical pattern:

  • The order is sent using an old Ask/Bid
  • The market price has already moved
  • The price is outside the allowed range → off-quotes

Example of a coding issue:

double price = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
// Time passes after this
OrderSend(request, result);

How to think about the fix:

  • Retrieve the price again immediately before placing the order
  • Use logic equivalent to RefreshRates where appropriate

2.2 Cause 2: insufficient allowed slippage (deviation)

If deviation, or allowed slippage, is too small,
the order can be rejected even when the price moves only slightly.

Example:

  • deviation = 0 to 5 → very strict
  • During sharp moves → execution is unlikely

Why it happens:

  • Execution is completed only within “specified price ± allowed range”
  • If the market moves outside that range, the order becomes invalid

Practical points:

  • Adjust based on volatility
  • Consider a dynamic value instead of a fixed value

2.3 Cause 3: spread widening

When the spread widens,
it can effectively create a state where no executable price is available.

Common timing:

  • Economic news releases
  • Rollover around the New York close
  • Low-liquidity trading hours

Example:

  • Normal: spread 1.0 pips
  • Abnormal: spread 5.0 pips or more

Impact:

  • The gap between Ask and Bid expands
  • Order conditions no longer match
  • off-quotes occurs

2.4 Cause 4: broker and liquidity structure

MQL5 execution depends on the broker’s execution model.

Main structures:

  • ECN/STP: direct market access, dependent on liquidity
  • DD (dealing desk): internal processing

Cases where off-quotes is more likely:

  • The LP (Liquidity Provider) side is thin
  • The execution queue is congested
  • Order processing is delayed

Key points:

  • The same EA can have a different error rate by broker
  • Execution quality directly affects profitability

2.5 Cause 5: communication latency (VPS and network)

If communication latency is high,
the price at the time of order submission may already be invalid.

Typical examples:

  • Home internet connection → server is far away
  • Ping of 100 ms or more
  • The price moves during that delay

Impact:

  • The order is sent with an old price
  • Deviation is exceeded
  • off-quotes occurs

Improvements:

  • Use a VPS close to the broker
  • Use a low-latency environment, preferably under 10 ms

2.6 Summary of causes

off-quotes occurs when these three elements are out of sync:

  • Price: not current
  • Conditions (deviation / spread): too strict
  • Time (latency): delayed

When all three shift at the same time, the error becomes very likely.


2.7 Common misunderstandings and cautions

Misunderstanding:

  • “A price exists, but the order cannot be placed, so it must be a bug”
    → In reality, the execution conditions do not match

Cautions:

  • It is hard to reproduce in backtesting
  • It often becomes visible only in live trading
  • High-frequency EAs are affected more strongly

3. How to fix mql5 off-quotes (How: steps)

[Conclusion]
off-quotes can be reduced significantly by implementing three things: retrieve the latest price, set an appropriate deviation, and add retry logic.

[Definition]
A fix means an implementation and operating method that minimizes the gap between order conditions and the market price, improving the execution success rate.


3.1 Basic checks: the fastest troubleshooting steps

First, separate environment and setting issues from EA logic issues.

Checklist:

  • Check whether prices are updating in Market Watch
  • Confirm that it is within trading hours and the market is open
  • Check whether the spread is abnormally wide
  • Check the connection status and ping of your network or VPS

Quick actions:

  • Restart MT5 to refresh the connection
  • Test again at another time, avoiding news events

Why this matters:
If environment factors are not excluded, you cannot correctly evaluate whether EA-side fixes work


3.2 EA fix 1: retrieve the latest price

Always retrieve the latest tick before sending an order.

Implementation example:

double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);

Improvement points:

  • Retrieve the price immediately before the order
  • Call OrderSend right after retrieval

Bad example:

  • Price retrieval → long logic processing → order submission, causing delay

Reason:
Prices can change in milliseconds, so an old price can become invalid immediately


3.3 EA fix 2: optimize deviation (allowed slippage)

deviation directly affects the execution success rate.

Recommended rough settings:

  • Normal conditions: 10 to 20
  • High volatility: 20 to 50

Implementation example:

request.deviation = 20;

Cautions:

  • Too small → more off-quotes
  • Too large → execution at an unfavorable price, increasing slippage

Practical balance:

  • Trade-off between fill rate and price accuracy

3.4 EA fix 3: retry logic (most important)

off-quotes is often temporary, so retrying often resolves it.

Implementation example:

int retry = 3;

for(int i=0; i<retry; i++)
{
   double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);

   request.price = ask;

   if(OrderSend(request, result))
   {
      if(result.retcode == TRADE_RETCODE_DONE)
         break;
   }

   if(result.retcode == TRADE_RETCODE_OFF_QUOTES)
   {
      Sleep(500); // Wait briefly
      continue;
   }
}

Points:

  • Retry count: 2 to 5 times is realistic
  • Use Sleep to wait for the market to stabilize
  • Always avoid infinite loops

3.5 EA fix 4: spread filter

When the spread is abnormal, it is important to choose not to place the order at all.

Implementation example:

double spread = (SymbolInfoDouble(_Symbol, SYMBOL_ASK) -
                 SymbolInfoDouble(_Symbol, SYMBOL_BID)) / _Point;

if(spread > 30) // Avoid when spread is 30 points or more
{
   return;
}

Reasons:

  • Even if the order executes, it may be unfavorable
  • The probability of off-quotes also rises

3.6 Environment fixes: VPS and broker

Improving the environment is also important, not just the EA.

Recommended:

  • Use a VPS close to the broker server
  • Aim for ping of 10 ms or less
  • Choose a broker with strong execution quality

Comparison points:

  • The same EA can produce different results
  • Fill rate is part of performance

3.7 Practical checklist for reuse

off-quotes prevention checklist:

  • The latest price is retrieved immediately before the order
  • deviation is set appropriately
  • Retry logic is implemented
  • A spread filter is in place
  • A low-latency VPS environment is secured

3.8 Common failures and cautions

Failure examples:

  • deviation = 0, which will almost certainly fail
  • No retry logic, meaning single-shot orders only
  • Ignoring spread
  • Not checking logs, leaving the cause unknown

Cautions:

  • Too many retries can lead to unfavorable execution
  • High-frequency EAs require more precise design

4. Comparing off-quotes with other errors

[Conclusion]
off-quotes is an error where “a price cannot be established,” and it differs from requote, where a price is re-offered, and no prices, where no price data exists. It is important to choose the fix based on the error type.

[Definition]
Error comparison means organizing the occurrence conditions, behavior, and fixes for each execution error so you can choose the correct response.


4.1 Error comparison table

ErrorMain causeTimingBehaviorMain fix
off-quotesPrice unavailable or conditions do not matchAt order submissionExecution failsRetrieve price again and retry
requotePrice moved beyond slippageImmediately before executionNew price is offeredIncrease deviation
no pricesNo price dataWhen the market is closedOrder cannot be placedCheck connection and market status

4.2 Difference between off-quotes and requote

These are the two errors most often confused.

Core difference:

  • off-quotes: no executable price exists
  • requote: a price exists, but it is outside the conditions and is re-offered

Specific behavior:

  • off-quotes → order is rejected and ends
  • requote → a new price is presented

Practical decision:

  • off-quotes → retry or loosen conditions
  • requote → adjust deviation

4.3 Difference between off-quotes and no prices

no prices means the market itself is not providing prices.

Difference:

  • off-quotes: prices are moving, but they do not match the order conditions
  • no prices: price data itself does not exist

Common situations:

  • off-quotes → news events and high-volatility conditions
  • no prices → weekends, holidays, or market close

Key points:

  • With no prices, execution will not occur no matter what you do
  • off-quotes can be improved by adjusting conditions

4.4 Difference between off-quotes and slippage

slippage is not an error. It is a difference in the execution result.

Difference:

  • off-quotes → execution fails and no trade occurs
  • slippage → execution succeeds, but at a different price

Relationship:

  • When deviation is widened
    • off-quotes decreases
    • slippage increases

In short:
Fill rate and price accuracy are a trade-off


4.5 Practical use: decision criteria

Response by error type:

  • off-quotes
    • Retrieve the latest price
    • Retry
    • Control spread
  • requote
    • Increase deviation
    • Adjust the allowed execution range
  • no prices
    • Stop trading
    • Check market hours

4.6 Common misunderstandings and cautions

Misunderstandings:

  • “Treat all errors the same”
    → The problem will not improve if the response does not match the cause
  • “requote and off-quotes are the same”
    → The causes and fixes are different

Cautions:

  • Always check the log, especially result.retcode
  • Implement branching logic for each error

Example:

if(result.retcode == TRADE_RETCODE_OFF_QUOTES)
{
   // Retry logic
}
else if(result.retcode == TRADE_RETCODE_REQUOTE)
{
   // Adjust deviation
}

4.7 Comparison summary

  • off-quotes: price cannot be established → retry
  • requote: price has moved → widen the allowed range
  • no prices: market is closed → wait

5. Common failures and cautions

[Conclusion]
Many off-quotes problems come from three causes: bad settings, weak design, and ignoring the environment. The typical failures are missing deviation settings, no retry logic, and ignoring spread.

[Definition]
Here, a failure means a state where avoidable off-quotes errors are caused by design or operational problems.


5.1 Wrong deviation setting: the most common issue

The most common cause is insufficient allowed slippage.

Typical examples:

  • deviation = 0 to 5
  • Ordering during high volatility
    → off-quotes is almost certain

Core problem:

  • The execution conditions are too strict
  • They do not match the real market

Fix:

  • Set at least 10 to 20 as a starting point
  • Adjust by currency pair and time of day

5.2 Not retrieving the latest price

Common coding mistakes:

  • Long processing after price retrieval
  • Sending OrderSend with that old price

Bad example:

double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);

// Logic processing (several hundred ms)

OrderSend(request, result);

Problems:

  • The price is already old
  • It can fall outside the deviation range

Fix:

  • Retrieve the price again immediately before the order
  • Avoid unnecessary processing between price retrieval and order submission

5.3 No retry logic

A common beginner design is to place the order only once.

Problem:

  • off-quotes is often temporary
  • One failure means a missed opportunity

Fix:

  • Implement 2 to 5 retries
  • Use a reasonable wait with Sleep

Caution:

  • Infinite loops are prohibited
  • Excessive retries can backfire

5.4 Ignoring spread

Spread directly affects whether an order can be executed.

Typical failures:

  • No spread check
  • Ordering during news events without filtering

Result:

  • More off-quotes
  • Unfavorable execution and slippage

Fix:

  • Set a maximum spread
  • Stop trading during abnormal conditions

5.5 Not considering market hours

This is an easy point to overlook.

Common cases:

  • Just before market close
  • Rollover time

Problem:

  • Liquidity decreases
  • Prices become unstable

Fix:

  • Add a trading time filter
  • Control trading by time period

5.6 Ignoring communication and VPS quality

Environment factors are also important.

Failure examples:

  • Running the EA from a home connection
  • High ping of 100 ms or more

Impact:

  • Price delay
  • Execution failure

Fix:

  • Use a VPS for low latency
  • Use a server close to the broker

5.7 Not checking logs

This is a surprisingly common serious mistake.

Problem:

  • The error cause remains unknown
  • You cannot improve the EA correctly

Fix:

  • Always check result.retcode
  • Implement log output

Example:

Print("Error code: ", result.retcode);

5.8 Practical prevention points

The core of off-quotes prevention is this:

  • Optimize execution and fill rate
  • Match the real market environment
  • Design the EA and infrastructure together

Especially important:

  • Design for the real market, not the ideal price

5.9 Summary of common misunderstandings

  • “If the EA logic is correct, there is no problem”
    → If execution is poor, profit will not follow
  • “Backtesting showed no problem”
    → Live trading is a different problem
  • “All brokers are the same”
    → Execution quality can differ significantly

6. Practical use in EA operation

[Conclusion]
off-quotes prevention is not just error avoidance. It is a core design element for optimizing fill rate and stabilizing an EA’s expected value and profitability.

[Definition]
Practical use means an operating design that builds execution quality into the strategy and reflects it in performance metrics such as PF and DD.


6.1 Role in EA design

off-quotes should not be treated as only exception handling. It should be built into the design as an assumed condition.

Impact areas:

  • Fill rate
  • Entry accuracy
  • Gap between backtesting and live trading

Structural understanding:

  • Entry logic alone does not create profit
  • Profit becomes real only when execution is completed

Key point:

  • Logic accuracy × execution quality = live trading performance

6.2 Impact on PF (profit factor)

off-quotes directly affects PF.

Impact mechanism:

  • Profitable trade → not executed, causing missed opportunity
  • Losing trade → executed, creating bias

Result:

  • Lower PF
  • Distorted strategy results

Example:

  • Theoretical PF: 1.5
  • Live PF: 1.2 or lower

Reason:

  • Trades with favorable conditions tend to be harder to execute

6.3 Relationship with DD (drawdown)

off-quotes also affects DD.

Pattern:

  • Profitable opportunities are missed
  • Losing trades are executed
    → DD increases

Especially risky:

  • High-frequency EAs such as scalping systems
  • News trading

Countermeasures:

  • Stabilize fill rate
  • Design with execution assumptions included

6.4 Trade-off with slippage

Important practical decision:

  • Widening deviation
    • Fill rate increases
    • Slippage increases
  • Narrowing deviation
    • Fill rate decreases
    • Slippage decreases

Conclusion:
The optimal setting differs by strategy

Example:

  • Scalping → stricter
  • Swing trading → looser

6.5 Recommended EA design pattern

Effective practical configuration:

Basic configuration

  • Retrieve the latest price
  • Set deviation
  • Add retry logic
  • Add a spread filter

Advanced configuration for intermediate users

  • Volatility-linked deviation
  • Time-of-day filter
  • Execution log analysis

6.6 Environment design: infrastructure strategy

Infrastructure matters as much as the EA.

Optimal setup:

  • VPS close to the broker
  • Low latency under 10 ms
  • Broker with strong execution quality

Key points:

  • The same EA can produce different results
  • Infrastructure is part of the strategy

6.7 Practical checklist before live operation

Always check before operation:

  • Fill rate, based on log analysis
  • off-quotes occurrence rate
  • Spread condition settings
  • deviation optimization
  • VPS operation status

6.8 Common practical failures

Failure examples:

  • Optimizing only the trading logic
  • Ignoring execution
  • Not considering broker differences

Result:

  • Large gap from backtesting
  • Live operation breaks down

6.9 Practical summary

  • Execution quality is part of the strategy
  • off-quotes is a variable to control
  • Execution design changes profitability

7. FAQ

[Conclusion]
off-quotes occurs through a combination of market, settings, and environment factors, so separating the cause is the fastest way to fix it.

[Definition]
This FAQ provides short, reusable answers to common practical questions.


7.1 Is off-quotes a bug?

No. It is a normal execution error caused by a mismatch among market price, slippage conditions, and communication latency.


7.2 What deviation value is appropriate?

General guidelines are:

  • Normal conditions: 10 to 20
  • High volatility: 20 to 50

However, the optimal value changes by currency pair and strategy, such as scalping or swing trading.


7.3 Will using a VPS always solve it?

It often improves the problem, but it does not eliminate it completely.
A VPS reduces latency, but liquidity issues and spread widening can still remain.


7.4 Why does off-quotes increase during news releases?

Main reasons include:

  • Sharp price movement and high volatility
  • Spread widening
  • Temporary decline in liquidity

As a result, an executable price may no longer exist.


7.5 How many retries are appropriate?

In general, 2 to 5 retries is realistic.

Reason:

  • Too few retries → missed execution opportunities
  • Too many retries → unfavorable execution or excessive trading

7.6 How much does spread affect off-quotes?

It has a major effect.
Spread widening can remove executable prices, increasing the likelihood of off-quotes.


7.7 Is there a difference between MT4 and MT5?

The basic concept is the same, but MT5 tends to handle execution more strictly and return clearer error codes.


7.8 Why does off-quotes not appear in backtesting?

Backtesting often assumes ideal execution.
Actual communication latency, liquidity, and spread changes are not fully reproduced, so live results can differ from backtest results.

8. Summary

[Conclusion]
mql5 off-quotes is an execution failure caused by a mismatch among price, conditions, and timing.
In practice, it can be controlled with latest-price retrieval, deviation optimization, and retry logic.


8.1 Key points from this article

  • off-quotes means the order fails because no executable price is established
  • The main causes are latency, spread, and liquidity
  • The fixes are price refresh, allowed range control, and retry logic

8.2 Most important practical points

  • Execution directly affects profit
  • Infrastructure matters, not only trading logic
  • Slippage and fill rate are a trade-off

8.3 Prevention checklist

  • Retrieve the latest price immediately before placing the order
  • Set deviation appropriately
  • Implement retry logic
  • Add a spread filter
  • Secure a low-latency VPS environment

8.4 Search intent coverage: fix, understand, compare

  • Fix: concrete troubleshooting steps are provided
  • Understand: the execution mechanism is organized
  • Compare: differences from requote and no prices are clarified

8.5 Final conclusion

off-quotes is not an unavoidable error.
It is a variable that can be controlled through design, settings, and environment.