Dealing with Requotes (Error 136) in EA Development
The Logic of the Missed Fill: What is Error 136?
In MetaTrader 4, Error 136 (Off Quotes) is one of the most frustrating obstacles for algorithmic traders. It occurs when your EA tries to send an OrderSend() command, but the broker's server rejects it because the price has already moved beyond your allowed slippage settings.
This is extremely common in Instant Execution accounts (B-Book brokers). Since the broker is taking the other side of your trade, they won't fill your order if their internal price has updated in the milliseconds it took for your request to reach their server. To the broker, the quote you requested is now 'Off' (dead).
Why Brokers Send Requotes
Frequent 'Off Quotes' errors during high-impact news usually mean your broker is actively rejecting your orders to protect their own exposure. To trade news-based algorithms effectively without constant rejections, you must migrate your capital to trustworthy forex brokers that utilize true A-book execution models with no dealing desk intervention.
{ Error 136 Resolution Checklist }
Primary: Increase the 'Slippage' parameter (at least 3-5 pips for news)
Logic: Implement a for-loop with RefreshRates() for order retries
Threshold: Limit retries to 5 attempts to avoid server flooding
Wait: Add a Sleep(100) between attempts to allow price stabilization
Verified: Check the 'Experts' tab for Error 138 (Requote) and 136
Infrastructure: Switch to ECN (Market Execution) for zero-requote fills
The Slippage Parameter: Your Tolerance Level
The most common cause of Error 136 is setting the 'Slippage' parameter too tight. If you set your slippage to 3 points (0.3 pips) and the market is moving fast during news, the price is guaranteed to move more than 0.3 pips during the internet transmission. The server sees the discrepancy and sends back Error 136.
Increasing your slippage parameter (e.g., to 30 points or 3 pips) is the quickest way to reduce requotes. This tells the broker: 'I am willing to accept a fill within 3 pips of the current price'. On an ECN/A-Book account, you rarely see Error 136 because they use Market Execution, where you are filled at the 'Next available price' regardless of slippage.
Coding the Fix: The Retry Loop
A professional MQL4 Expert Advisor should never give up after one failed execution. You should implement a Retry Loop that catches Error 136. If the EA receives an 'Off Quotes' code, it should use the RefreshRates() function to fetch the latest price and then attempt to send the order again.
Example: for (int i=0; i<5; i++) { if (OrderSend(...) > 0) break; if (GetLastError() == 136) { RefreshRates(); Sleep(100); } }. This loop gives the EA 5 chances to catch a valid quote. By adding a small Sleep(100) (100 milliseconds), you give the broker's bridge time to stabilize its internal quote feed.
Context: Requotes vs. Slippage
While requotes are annoying, they can actually be a 'Protection' mechanism on Instant Execution accounts. They prevent you from being filled at a terrible price. However, in the fast-moving 24/5 Forex market, most institutional traders prefer Slippage over Requotes. They would rather be filled 1 pip away than not be filled at all. This is why most advanced algo developers migrate from 'Standard' accounts to 'ECN/Raw' accounts as their capital grows.