Error 138 - how to overcome requote

thread: Error 138 - how to overcome requote

  1. #1
    Junior Member RittraderRS's Avatar
    17

    Error 138 - how to overcome requote

    Hello guys
    I've my EA coded with RefreshRates according to following, but I have requote and also my EA stop sending new CloseOrder after 1 or 2 attempt. How to I write a code that will ask my EA to maintain sending CloseOrder before it approved by the broker host? Thank you

    for (int I=0; I lt; RepeatN; I )

    RefreshRates();
    bool res = CloseOrder(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID));
    if (res) break;

  2. #2
    Yeah, it is simple. Just choose the order and state if OrderCloseTime()==0 (meaning it is not closed yet since the close time does not exist yet), and just make a loop. Fxid10t is accurate.

  3. #3
    Int I OrdersTotal();

    while(OrdersTotal()==I)
    OrderClose(...);

  4. #4
    I get re-quotes when utilizing OrderSend, how can I get the EA to try again once more if this happens? This mostly occurs with my Live account and the order isn't placed. I'd like it to try again.

    This is the code;
    int ticket36 = OrderSend(emblem, cmd, Lot, price, Slippage, 0, 0, con, a_magic_20, 0, CLR_NONE);
    if (ticket36 lt; 0)
    error = GetLastError();
    Printing (Order send failed with error(, error, ):, ErrorDescription(error));
    return (0);

    return (1);
    }


    What if I do? Could I include RefreshRates(); before the OrderSend? Or...
    Thank you

  5. #5
    Junior Member Gerardomoreno84's Avatar
    22
    I get re-quotes when utilizing OrderSend, how can I get the EA to test once more if this happens? This mainly occurs with my Live account and the order is not placed. I would like it to test again.

    Here is the code;
    int ticket36 = OrderSend(emblem, cmd, Lot, price, Slippage, 0, 0, con, a_magic_20, 0, CLR_NONE);
    if (ticket36 lt; 0)
    error = GetLastError();
    Print(Order send failed with error(, error, ):, ErrorDescription(error));
    return (0);

    yield (1);
    }


    What if I do? Could I add RefreshRates(); before...
    thousands of individuals confront this problem

    just don't utilize BID with Buy or ASK with sell

    this root description of mistake 138

    it isn't related to broker reqoute at all, but to your poor layout

    of course refresh rates must not solve the pproblem as it isn't a issue of historic data

    why reqoute happen in backtesting?
    Ans: u place inapproprite price,

  6. #6
    Junior Member Pelirrojaaa13's Avatar
    17
    thousands of people confront this problem

    simply do not use BID with Buy or ASK with sell

    this root description of mistake 138

    it is not associated with broker reqoute in any way, but to your poor design

    of course refresh rates must not address the pproblem as it is not a issue of historical data

    why reqoute occur in backtesting?
    Ans: u set inapproprite price,
    Error 138 covers from date prices and mixed up Bid and Ask...

    From here: http://docs.mql4.com/trading/errors

    ERR_REQUOTE138

    The requested price has become out of date or bid and ask prices are mixed up. The information can be refreshed with no delay using the RefreshRates purpose and produce a retry. If the mistake does not vanish, all attempts to trade must be stopped, the program logic must be changed.

  7. #7
    Get the common_functions record here https://sites.google.com/site/prof7bit/common_functions

    Place that document in to your include folder

    put this into your EA:

    #include lt;common_functions. Mqhgt;

    Then you can call a buy or sell as follows:

    buy(double lots, double sl, double tp, int magic = 42, string comment = )

    There are a lot of powerful functions in the typical functions include file, ones that I use greatly because of the EA development.

    Another thing to test, set your OrderSend function = to some boolean variable and check whether it returns true. If it does not then repeat the command.

  8. #8
    Junior Member Pelirrojaaa13's Avatar
    17
    Another thing to try, place your OrderSend function = to some boolean variable and check whether or not it returns true. If it doesn't then repeat the command.
    Http://docs.mql4.com/trading/OrderSend returns an int, not a bool.

    Returns number of this ticket assigned to this order by the transaction server or -1 if it fails. To acquire additional error information, one needs to call the GetLastError() function.


    http://forum.mql4.com/48276

  9. #9
    Junior Member YenaySani's Avatar
    14
    I had the exact same problem as I am a newbie to MQL4. I had been seeing the error 138 but appears to be working alright but I got upset with this error so I checked other threads and read about changing the slippage value. I did a little trial and error. Modified the slippage worth from 10 to 11 until I came to 15. The error was gone with slippage worth 15. I expect you can try this fix. The RefreshRates() function didn't help eliminating the mistake. I hope this one helps. God bless.

    IsOkay = OrderClose(OrderTicket(), OrderLots(), Bid, 15); // 15 is the acceptable slippage. Otherwise error in OrderClose occurs.

  10. #10
    Hello men
    I have my EA coded with RefreshRates according to day, but I still have requote and also my EA stop sending new CloseOrder following 1 or two try. How to I write a code that can ask my EA to maintain sending CloseOrder until it accepted from the broker server? Thank you

    for (int I=0; I lt; RepeatN; I )

    RefreshRates();
    bool res = CloseOrder(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID));
    if (res) break;
    Try using the While cycle operator,

    Inserted Code OrderSelect(orderticket,SELECT_BY_TICKET,MODE_TRAD ES) while(/*order closing standards is true*/ OrderCloseTime()==0) for (int I=0; t lt; RepeatN; I ) RefreshRates(); bool res = OrderClose(OrderTicket(),OrderLots(),Bid,1,0); if (res) break; and possibly look at adding a pip for slippage when the requote difficulty persists.

  •