avoid requotes

 
//Sell position------------------------------------------------------------------------------------------------------------      
 if(
    ObjectFind("Sell")        !=        -1           &&
    Bid                       >=        Line_Sell    &&
    Bid_last_tick             <         Line_Sell    ||
    (Bid                      <=        Line_Sell    &&
    Bid_last_tick             >         Line_Sell )  &&
    SELL                      <         1            &&
    new_sell_allowed          ==        true
   )
      {
       int ticket_Sell = 0;
         while (ticket_Sell <= 0)
            ticket_Sell=OrderSend(Symbol(),OP_SELL,lot,NormalizeDouble(Bid,Digits),1,Line_Sell_SL, Line_Sell_TP,"Ordername",magicnumber,0,Black);
      }

Hi Guys!

As I had problemes with requotes I inserted while (ticket_Sell <= 0)... But I still get requotes. Is someone able to help me?

Thanks a lot in advance!


Regards, Jan.
 
If you are doing a lot of processing during a tick before you place your order it is possible that your Bid may be out of date . . . you don't need the NormailizeDouble on Bid . . . . get rid of it. Before your OrderSend add a RefreshRates() if you think your Bid might be old . . . you might want to allow more slippage than 0.1 pip (if your Broker is 5 digits)
 
RaptorUK:
If you are doing a lot of processing during a tick before you place your order it is possible that your Bid may be out of date . . . you don't need the NormailizeDouble on Bid . . . . get rid of it. Before your OrderSend add a RefreshRates() if you think your Bid might be old . . . you might want to allow more slippage than 0.1 pip (if your Broker is 5 digits)

Thanks! I think the hint about slippage will help!
 
EAs must adjust for 4/5 digit brokers, tp, sl, AND SLIPPAGE. EAs must adjust for ECN brokers (open first, THEN set stops)
//++++ These are adjusted for 5 digit brokers.
int     pips2points;    // slippage  3 pips    3=points    30=points
double  pips2dbl;       // Stoploss 15 pips    0.015      0.0150
int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)
int     init(){                                                     OptParameters();
     if (Digits % 2 == 1){      // DE30=1/JPY=3/EURUSD=5 https://www.mql5.com/en/forum/135345
                pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
    } else {    pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; }
    // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
//---- These are adjusted for 5 digit brokers.
    /* On ECN brokers you must open first and THEN set stops
    int ticket = OrderSend(..., 0,0,...)
    if (ticket < 0)
       Alert("OrderSend failed: ", GetLastError());
    else if (!OrderSelect(ticket, SELECT_BY_TICKET))
       Alert("OrderSelect failed: ", GetLastError());
    else if (!OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0)
       Alert("OrderModify failed: ", GetLastError());
     */
 

That is a very nasty infinite loop you have written there.

      {
       int ticket_Sell = 0;
         while (ticket_Sell <= 0)
            ticket_Sell=OrderSend(Symbol(),OP_SELL,lot,NormalizeDouble(Bid,Digits),1,Line_Sell_SL, Line_Sell_TP,"Ordername",magicnumber,0,Black);
      }

If it didn't work the first 100 times it is not going to work after that is it?

If the OrderSend fails then you must RefreshRates as a very minimum because that could be 3 or 4 seconds later. I would also limit the loop to 3 or 4 trys using a for loop, breaking when the ticket is valid and reporting the error if it is not valid.

As an additional guard you might try checking the spread. If the spread is double its usual value it may not be a good idea to try opening a position.

 

It seems to me that you will not getting only requote errors

it can be also you get trade context too busy errors.... with such kind of loop

 

Thaks for the answers! :)

I did adjusted the slippage for 5 digits. I still get requotes. But why do I only get one error message in my journal? Shouldn´t there be an error messages until the order is filled because it is a while loop?

Here is the journal. Everytime the price hit my entry level I got one message until the order got filled at 10:08.

2012.05.29 10:08:27 : order was opened : #2680678 sell 2.00 GBPAUD at 1.59498 sl: 1.59808 tp: 1.55196
2012.05.29 10:08:27 : request in process
2012.05.29 10:08:26 : request was accepted by server
2012.05.29 10:08:26 : instant order sell 2.00 GBPAUD at 1.59498 sl: 1.59808 tp: 1.55196
2012.05.29 10:00:10 : order sell 2.00 GBPAUD opening at 1.59498 sl: 1.59808 tp: 1.55196 failed [Off quotes]
2012.05.29 10:00:10 : request in process
2012.05.29 10:00:10 : request was accepted by server
2012.05.29 10:00:10 : instant order sell 2.00 GBPAUD at 1.59498 sl: 1.59808 tp: 1.55196

2012.05.29 09:59:57 : order sell 2.00 GBPAUD opening at 1.59498 sl: 1.59808 tp: 1.55196 failed [Off quotes]
2012.05.29 09:59:57 : request in process
2012.05.29 09:59:57 : request was accepted by server
2012.05.29 09:59:57 : instant order sell 2.00 GBPAUD at 1.59498 sl: 1.59808 tp: 1.55196
2012.05.29 09:53:59 : order sell 2.00 GBPAUD opening at 1.59498 sl: 1.59808 tp: 1.55196 failed [Off quotes]
2012.05.29 09:53:59 : request in process
2012.05.29 09:53:59 : request was accepted by server

2012.05.29 09:53:59 : instant order sell 2.00 GBPAUD at 1.59498 sl: 1.59808 tp: 1.55196


I am goiong to code my opern order function with refresh rates and a loop that is not infinite, but I wonder if a loop could help me, when even a infinite is only executed once!?!

 
5 digit broker and you have 1 point slippage, try 1.5 pip (= 15 points).
 
APeng:

Thaks for the answers! :)

I did adjusted the slippage for 5 digits. I still get requotes. But why do I only get one error message in my journal? Shouldn´t there be an error messages until the order is filled because it is a while loop?

I am goiong to code my opern order function with refresh rates and a loop that is not infinite, but I wonder if a loop could help me, when even a infinite is only executed once!?!


Assuming the first OrderSend in the loop fails and then you retry in the loop . . . what is the frequency that you are saying to your Broker . . . .

OrderSend(Symbol(),OP_SELL,lot,NormalizeDouble(Bid,Digits),1,Line_Sell_SL, Line_Sell_TP,"Ordername",magicnumber,0,Black);

. . . do you expect a reply from your Broker saying failed [Off quotes] for each of your many OrderSends that you are sending . . . add a print like this and you will know how many times you are shouting ORDERSEND at your Broker . . . like an impatient child.

int TryNumber = 0;

while (ticket_Sell <= 0)
   {
   tryNumber++;
   Print("Loop:  Trying to send Order . . again, # ", TryNumber)
   ticket_Sell=OrderSend(Symbol(),OP_SELL,lot,NormalizeDouble(Bid,Digits),1,Line_Sell_SL, Line_Sell_TP,"Ordername",magicnumber,0,Black);
   ]

Please write you code as you might hope an Adult would behave and not a Child . . .

 
onewithzachy:
5 digit broker and you have 1 point slippage, try 1.5 pip (= 15 points).
thx, I already did that.
 
RaptorUK:

Assuming the first OrderSend in the loop fails and then you retry in the loop . . . what is the frequency that you are saying to your Broker . . . .

. . . do you expect a reply from your Broker saying failed [Off quotes] for each of your many OrderSends that you are sending . . . add a print like this and you will know how many times you are shouting ORDERSEND at your Broker . . . like an impatient child.

Please write you code as you might hope an Adult would behave and not a Child . . .

...sometimes the loudest achieves the most attention ;)

So I understand your answer as it is no failure in the code, it is the broker who only answers once per identical question :P

Reason: