Broker requotes my prices

 

Hello I have a problem with requotes and need your advice.

When I send an open or close order to a broker, he sends me requotes so many times that it throws a TOO_MANY_ORDERS error. How do you guys handle that error? I mean, I have created a function that resends the request to him again and again until he executes it or throws that error, but my question is, how many times is it reasonable to resend the order and stop after it? 10, 20, ..., 100 times? Please see the count variable. Also related to this question: why does broker leave my orders open sometimes? e.i. when I send an order to close 20 orders he might close 18 and leave 2 open. How can I handle this as well? Thank you

void CloseLongs()
{
   int count = 1;
   bool status = false;
   for(int i = 0; i < OrdersTotal(); i++)
   {
      if(count > 20) continue;
      if(OrderSelect(i, SELECT_BY_POS) == true)
      {
         while(true)
         {
            RefreshRates();
            status = OrderClose(OrderTicket(), OrderLots(), Bid, 3);
            if(status == true) break;
            
            //some error processing logic here..
            count++;
         }
      }
   }
}

 
mkheidzedavid:

Hello I have a problem with requotes and need your advice.

When I send an open or close order to a broker, he sends me requotes so many times that it throws a TOO_MANY_ORDERS error. How do you guys handle that error? I mean, I have created a function that resends the request to him again and again until he executes it or throws that error, but my question is, how many times is it reasonable to resend the order and stop after it? 10, 20, ..., 100 times? Please see the count variable.

Requotes error ? you mean error 138


This is what you should do:

"The requested price has become out of date or bid and ask prices have been mixed up. The data can be refreshed without any delay using the RefreshRates function and make a retry. If the error does not disappear, all attempts to trade must be stopped, the program logic must be changed."

from here: Trading errors


. . . so make one retry if that doesn't work fix your code.

 

Hi, thanks for your answer. Not 138, it is error 141 = ERR_TOO_MANY_REQUESTS.

If the requested price has become out of date, Im handling that in my while cycle...I RefreshRates() and resend again

 
mkheidzedavid:

Hi, thanks for your answer. Not 138, it is error 141 = ERR_TOO_MANY_REQUESTS.

If the requested price has become out of date, Im handling that in my while cycle...I RefreshRates() and resend again

OK, but what is the error related to requotes that you are getting ? error 141 is being caused by your code . . . what error are you trying to address ? if it's error 138 you can't simply keep resending or that action can cause error 141.
 
Ah now I got it. So Im not completely sure it is related to requotes, but the problem is such, when I request to close 20 orders there are situations when it closes only 18 and leaves 2 open. I blamed it on requote but you made it clear and now I understand that requote is not guilty. So why does it happen?
 
mkheidzedavid:
Ah now I got it. So Im not completely sure it is related to requotes, but the problem is such, when I request to close 20 orders there are situations when it closes only 18 and leaves 2 open. I blamed it on requote but you made it clear and now I understand that requote is not guilty. So why does it happen?
OK, it happens because your loop is counting up and it needs to count down . . . it's explained here: Loops and Closing or Deleting Orders
 
Thank you very much you've been very helpful.
 
mkheidzedavid:
Thank you very much you've been very helpful.


the selected order can be having other Symbol() also

Closing at Bid won't help in that case...

 
mkheidzedavid: Hello I have a problem with requotes and need your advice.

status = OrderClose(OrderTicket(), OrderLots(), Bid, 3);

Adjust for 4/5 digit brokers. Slippage of 0.3 pips?
 
deVries:


the selected order can be having other Symbol() also

Closing at Bid won't help in that case...


No, the symbol is filtered out in the for cycle. I didn't include in order to concentrate only on the actual problem. Thanks

WHRoeder:
Adjust for 4/5 digit brokers. Slippage of 0.3 pips?


Thank you Ill take this into consideration. Is there any other thing I should adjust for 4/5 digit brokers? I mean, if lots, open price (bid or ask) or stops need to be adjusted for that...
 
mkheidzedavid:


No, the symbol is filtered out in the for cycle. I didn't include in order to concentrate only on the actual problem.


Don't agree. If you so sure it is filtered out in the for cycle then show me how .......

Let me learn from you...

Reason: