Off Quotes Error in MT4

 
I've written an expert for MT4 that is giving ERR_OFF_QUOTES errors trying to modify an existing order. I place the order in the first step with OrderSend,
and receive an acknowledgment that this was successful. I then try to modify the order for the StopLoss and Profit Target with what seem to me to be valid

values, but receive the error. The broker requires that the stop loss and profit target be done in a second step after the order is placed.

The sample from this morning is shown below forthe eurusd:


      ticket=OrderSend(Symbol(),OP_BUY,Lots,NormalizeDouble(EntryPrice,Digits),Slippage,0,0,ExpertName,ExpertID,Expiration,Green);
      if ( ticket>0 )
      {
        if ( OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES) )
        {
          EntryPrice = OrderOpenPrice();
          if ( OrderModify(OrderTicket(), OrderOpenPrice(),NormalizeDouble(StopLoss,Digits),NormalizeDouble( EntryPrice + ( ProfitTarget * Point ),Digits),0,CLR_NONE) )
          {
            // Do some stuff

EntryPrice is initially 1.3674
StopLoss is 1.3644
EntryPrice+(ProfitTarget*Point) = 1.3719

Can someone please explain why this should result in an error 136 (Off Quotes)?

Thanks in advance.
 

From the documentation section:


ERR_OFF_QUOTES136No quotes. The broker has not supplied with prices or refused, for any reason (for example, no prices at the session start, unconfirmed prices, fast market). After 5-second (or more) delay, it is necessary to refresh data using the RefreshRates function and make a retry.

Hope that helps :)

 
Hello,
Normally OFF QUOTES happens when you want to set your order limits to a certain price and the price has already moves to some other value: for example, you want to buy at 1.5050 but the time your order arrive on the market the price is at 1.5060, so your order is rejected because there is too much difference with what you ask.
Use the parameter SLIPPAGE for acceptance of that difference or not. With a slippage of 3, most of your orders will be accepted: means if you ask to buy at 1.5050 and price is 1.5053 your order will be opened.
Hope that helps too :-)
 

Thanks for the responses, guys, but I'm not sure that explains it.


The Off_Quotes error is being returned by the OrderModify not the OrderSend, so slippage isn't the issue. This particular broker doesn't support slippage anyway. They have modified MT4 for market orders in that regard.


As shown with the example values (the real ones that caused the error), the stop loss was 30 pips from the entry and take profit was 45 pips from the entry. My log file shows that the bid and ask hadn't moved between the OrderSend and OrderModify. That is what puzzles me.


Any other thoughts would be appreciated.

 
Well, so the first answer might be the right one : your broker's server should have been disconnected or not responding when it happens.
Have you tried to do it manually ?
 
I frequently get the same error when I'm exiting a trade manually simply using the "close" bar on the order page.
 
cody_r wrote >>
I frequently get the same error when I'm exiting a trade manually simply using the "close" bar on the order page.

Sounds like a recipe for disaster to me, busy market and you are in with no stop loss, until your brokers software gets around to letting you set it.

I think I'd be looking for a different broker, where is the advantage to you in this setup? pardon my paranoia but this whole idea sounds scary.

Keith

 
No argument there, Keith.
Reason: