Forex Blog

First-hand Forex trading experience and information about foreign exchange market that will be useful to traders


OrderSend Error 138 (Requote)

October 31, 2010 (Last updated on October 11, 2018) by

OrderSend Error 138 (or ERR_REQUOTE) may appear during the execution (but not backtesting) of the MetaTrader expert advisors (only in MT4, as the MetaTrader 5 platform uses a different system of OrderSend error codes). Error 138 means that the broker replied with a “Requote” signal to your expert advisor’s OrderSend() function. That means that the price used in the order is outdated compared to the current market price. There are two main reasons for this error to appear:

  1. The order price is completely outdated and is not present in the recent quotes. The order will not be executed (and the error 138 will be generated) even if the current market price is within the given Slippage from the order price.
  2. The order price is present in the recent quotes but differs from the current market price by more than the given Slippage parameter.

To avoid getting OrderSend Error 138 from your expert advisors, you have to use RefreshRates() function call immediately before OrderSend() function and before you use the Ask/Bid to calculate parameters of OrderSend() function. This will save you from the first of the cases listed above, but only if your broker is not experiencing any technical problems; if it does, there is little you can do with that.

Additionally, you should specify a rather high slippage in the parameters of the OrderSend() function to prevent error 138 from appearing during very volatile conditions. Even if you use the RefreshRates() function, there is a possibility that prices will change between the call of RefreshRates() and the call of OrderSend(). Setting a tolerable slippage of 5–10 pips (normal, not fractional) will allow your expert advisors to execute orders without requote errors. Of course, if you are scalping or otherwise aiming for small profit targets, you should set a much lower slippage parameter and bear with the error 138 and failed orders. As an alternative option, you can always switch your Forex broker to one with less slippage and fewer requotes.

If you have any thoughts, comments, or questions regarding MT4 OrderSend Error 138 and the ways to treat it, feel free to reply to this post using the form below.

8 Responses to “OrderSend Error 138 (Requote)”

  1. Alfredo Brandr

    Dear trader,

    in my case, the Error 138 appears every time if I try to close an opened order. I show you the code, which returns this error:

    void CloseMagic() {
       int i,Ticket1,Lots1,OpenPrice1,Cmd1,Ticket2,Lots2,OpenPrice2,Cmd2;
       for(i=0;i<=OrdersTotal();i=i+2) {
          if(OrderSelect(TicketArray[i],SELECT_BY_TICKET)) {
          if(OrderSelect(TicketArray[i+1],SELECT_BY_TICKET)) {
          if(Cmd1==OP_BUY && Cmd2==OP_SELL) {
       if(Error!=0) Print("Error de CloseMagic: ",Error);

    I think, that you could include this error in your (very good) article, when it appears in relation of the OrderClose function.

    As you can see, I'n selecting an order normally, and then trying to close it normally. Then appears Error 138.

    Thank you very much!!


    admin Reply:

    I would be surprised to find out that this code can close any orders. You should try using SELECT_BY_POS instead of SELECT_BY_TICKET in this case.


  2. Alfredo Brandr

    Yes, but in the array called TicketArray are stored the tickets of all my orders… I’m not using the trading pool for it. That is because I can’t use or modify the magic number of orders for other reasons.

    I had write the RefreshRates() command line before open every order (that should be closed with this function), and the problem is the same…

    Thank you for your response.
    (And excuse me for my english, but I speak spanish and german, but no english).


  3. Alfredo Brandr

    Aha! I discovered this:
    This error appears in the Strategy tester when I test this EA. But in real mode (with an demo account), it works finely. AHA!!
    Thank you very much for your patience.


    admin Reply:

    Glad to know that, but it doesn’t explain why your code doesn’t work in Strategy Tester. Could you please share the whole EA, or is it too private?


    pta Reply:

    Hi, couldn’t it be because you are calling OrderClose with the preferred closing price set to the order’s open price? You should close buy orders at Bid price and sell orders at Ask price.


  4. Peter Wullems

    One should be able to confugure requotes off in the strategy tester of metatrader 4 but I can’t find a way to do so. I use an STP-NDD broker so there are never requotes. The ask and bid prices are on the server side, not client side, so if using what is the current price and guaranteed no requotes, it should be possible to set slippage to 0. That works for opening trades just fine but for some totally misguided reason the same does not apply in the strategy tester to OrderClose() and I get 138 errors on attempting to close. Here I repeated get 138 errors even when calling RefreshRates() which should also not be necessary as one is actually asking to close a trade at the going price on the server, not the rate on the client terminal. No round trip back to the client is therefore necessary at all and the order should just be closed and confirmed as such. Then the results from the strategy tester would be meaningful. In the absence of being able to do this, testing is by way of running on a demo platform so the possibility of using historical data offline with no requotes is not there.

    A simple addition of a tester.ini file or perhaps an xml config file could fix this easily and probably exists somewhere but all my browser searches do not reveal any such functionality.

    If indeed such a file or configuarion is possible and exists I would dearly love to hear of it.

    The end result is that any run of the tester having one or more 138 errors gives an incorrect test result and makes testing quite useless.

    I think that having requotes in the tester was asked for and put in place before the advent of STP-NDD brokers was available.


    Andriy Moraru Reply:

    There are no requotes in backtesting. The most likely reason for the error 138 appearing on OrderClose() in your case is some problem in the program’s logic. Could you please share the source code of the EA you are testing?


Leave a Reply

required (will not be published)