MT4 · code and request checks
MT4 error 138: why a valid signal can still miss its entry
Your entry can fail with error 138 even when the signal is right: my older quote failed, the current quote passed. If your EA stores an entry price and sends it later, inspect that stored value first. A retry with the same old price leaves the cause in place.

Arnold Holm · 2026-10-12
What the error means
A trader asked, "how can i use them correctly ? before the order is triggered or after the error?" The question followed a backtest that missed trades with error 138 after a spread change. The useful distinction is between refreshing the terminal prices and replacing the value you actually send. RefreshRates does not rewrite a price you copied into another variable earlier. I reproduced the price problem in the native MT4 Strategy Tester, build 1491, on EURUSD H4. I kept the first Ask, 1.2054, until the next bar. The current Ask was then 1.2041. With the same allowed 0.10 lot size, no stops and zero slippage, the old price returned ticket minus one and error 138. The current price returned ticket 1 and error 0. Reading the opened simulated order confirmed 1.2041. That is one missed entry caused by the price supplied to the request, rather than by the signal. I fix the price used by the request before widening slippage, because accepting a worse entry changes the trade.
Three code paths to check
1. A copied price survives the refresh
Look at where your entry price is assigned. If it was captured before a long calculation, a wait or a later bar, reading fresh Ask elsewhere does not update it. Put the quote read next to the send step. For a market BUY, inspect Ask. For a market SELL, inspect Bid. Keep the requested price and both quotes in the same log line so you can see which value the EA used.
2. The request uses the wrong symbol or side
Check the symbol written in the order request against the symbol supplying its price. Chart Ask belongs to the chart symbol. An EA trading another symbol needs that symbol’s quote. A BUY built with Bid can be outside the allowed price even though Bid is fresh. Confirm symbol, direction and requested price together before changing your indicator or entry rule.
3. A retry repeats the rejected request
Sending the same stored number again does not repair a stale quote. First capture the error from the failed request. Then read a fresh quote and decide whether your original entry rule still allows the trade. Limit the attempts. A price that has moved far enough can make the original trade unsuitable, even when a later request could technically open.
The two requests from my native test
The lot size, side, symbol and slippage stayed the same. I changed the requested price from the earlier Ask to the current Ask. The test program only runs inside the Strategy Tester. It also selected the successful simulated order and compared its open price with the price sent, then closed that simulated order. The screenshot below shows both requests and their actual return values.
double lots=MarketInfo(Symbol(),MODE_MINLOT);
double currentAsk=Ask;
ProofLine("terminal_build="+IntegerToString((int)TerminalInfoInteger(TERMINAL_BUILD))+" tester=1 account_orders_sent=0");
ProofLine("symbol="+Symbol()+" old_ask="+DoubleToString(oldAsk,Digits)+" current_ask="+DoubleToString(currentAsk,Digits));
ResetLastError();
int bad=OrderSend(Symbol(),OP_BUY,lots,oldAsk,0,0,0,"FIX08 old historical price",607,0,clrNONE);
int badError=GetLastError();
ProofLine("before price="+DoubleToString(oldAsk,Digits)+" ticket="+IntegerToString(bad)+" error="+IntegerToString(badError));
ResetLastError();
int good=OrderSend(Symbol(),OP_BUY,lots,currentAsk,0,0,0,"FIX08 refreshed price",607,0,clrNONE);
int goodError=GetLastError();
ProofLine("after price="+DoubleToString(currentAsk,Digits)+" ticket="+IntegerToString(good)+" error="+IntegerToString(goodError));This was one offline MT4 tester case with simulated EURUSD orders and no account orders, so check the intended demo account separately.
How you know it is fixed
Before: older quote
The retained Ask was 1.2054 and the current Ask was 1.2041. The request at the older price failed with error 138. Save the actual error at that point, before another function changes it.
After: current quote
The request at 1.2041 returned ticket 1 with error 0. Selecting that simulated order showed the same open price. Compare the order itself with the request rather than judging success from a printed message alone.
Your five-minute check
Open one failed entry in your Journal and compare its requested price with the Bid and Ask captured immediately before that request. Then trace where the requested price was assigned. If the same old value survives every retry, fix that assignment first.
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?
SOLVED-FIRST: one small fix or change to your own case, shown first as screenshots or a short screen video. 15 USD fixed (or the higher platform minimum), first five paid orders only during 4–17 October 2026. The file follows within 24 hours after funding. Close on Upwork first; marketplace cases stay on their marketplace.
Outside that sprint: R49: one authorised, reproducible MT4/MT5 defect, 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
Should I increase slippage first?
First verify the price and its symbol. Official MQL4 documentation says a fully outdated requested price can return 138 regardless of slippage. Wider slippage also changes which entry prices you permit. Choose that tolerance from your trading rule after correcting the quote handling.
Should I refresh before sending or after a rejection?
Refresh and read the price immediately before a market request. After a rejection, record the error and reassess the entry with a new quote before any bounded retry. Do not keep sending the old price just because the original signal was true.
Sources and limits
- Trader question: refresh before sending or after error 138?
- Official MQL4 OrderSend price and requote rules
- Own native MT4 Journal: older quote 138, current quote accepted
These public questions explain the error; use your own EA log to check whether the same cause applies.