error 141 - ERR_TOO_MANY_REQUESTS

 
     if( OpenOrdersThisPair(Symbol()) == 0 && LotSize_Buy >= minlot )
         { 
         BuyTicketOrder1 = OrderSend(Symbol(),OP_BUY,LotSize_Buy,Ask ,3,
                                             0,0,NULL,MagicNumber1,0,Green);RefreshRates();
                                                if( OrderSelect(BuyTicketOrder1,SELECT_BY_TICKET)==true){
                                                      if(OrderSymbol() == Symbol() && OrderType() == OP_BUY )
                                                         bool ModifyBuy1 = OrderModify(BuyTicketOrder1,OrderOpenPrice(),BuyStopPrice,btp1,0,clrNONE);}
                                                
                                                
         BuyTicketOrder2 = OrderSend(Symbol(),OP_BUY,LotSize_Buy2,Ask ,3,
                                             0,0,NULL,MagicNumber1,0,Green);RefreshRates();
                                                if( OrderSelect(BuyTicketOrder2,SELECT_BY_TICKET)==true){
                                                     if(OrderSymbol() == Symbol() && OrderType() == OP_BUY )
                                                        bool ModifyBuy2 = OrderModify(BuyTicketOrder2,OrderOpenPrice(),BuyStopPrice,btp2,0,clrNONE);}
                                             
         BuyTicketOrder3 = OrderSend(Symbol(),OP_BUY,LotSize_Buy3,Ask ,3,
                                             0,0,NULL,MagicNumber1,0,Green);RefreshRates();
                                                 if( OrderSelect(BuyTicketOrder3,SELECT_BY_TICKET)==true){
                                                     if(OrderSymbol() == Symbol() && OrderType() == OP_BUY )
                                                        bool ModifyBuy3 = OrderModify(BuyTicketOrder3,OrderOpenPrice(),BuyStopPrice,btp3,0,clrNONE);}
                                                        
         BuyTicketOrder4 = OrderSend(Symbol(),OP_BUY,LotSize_Buy4,Ask ,3,
                                             0,0,NULL,MagicNumber1,0,Green);RefreshRates();
                                                   if( OrderSelect(BuyTicketOrder4,SELECT_BY_TICKET)==true){
                                                     if(OrderSymbol() == Symbol() && OrderType() == OP_BUY )
                                                        bool ModifyBuy4 = OrderModify(BuyTicketOrder4,OrderOpenPrice(),BuyStopPrice,btp4,0,clrNONE);}

...
Called on tick when Bid >= EntryPrice.

In relation to previous thread, this is what i was concerned about using Market Orders over pending orders...
 
If the server is busy processing numerous trades whether that be market orders or pending orders, how do I keep retrying until the OrderSend is successful?
 
DomGilberto:
If the server is busy processing numerous trades whether that be market orders or pending orders, how do I keep retrying until the OrderSend is successful?

There was guidance in the old documentation about what you are meant to do in response to errors  . . .  in their wisdom Metaquotes removed it when they updated the Documentation.

Have a read:  https://www.mql5.com/en/forum/150158 

 

Nice one thanks.

 I tried using the code above to place trades and it just spat out 3 of the 4 and returned that error.

So how do I:

ERR_TOO_MANY_REQUESTS141Too many requests. The frequency of requesting must be reduced, the program logic must be changed.
 
You have to change you program logic like add a sleep(1000); ?
 
Yea I thought that but to get a little more deeper, I am trading 10 markets with up to 4 trades per market. Adding a sleep with a random period is a little vague. Is there anyway of knowing when the server is not busy for me to push through a trade, or more importantly know how frequently I can send an OrderSend?
 
Btw I guess you mean sleep like this:

   if( OpenOrdersThisPair(Symbol()) == 0 && LotSize_Buy >= minlot )
         { 
         BuyTicketOrder1 = OrderSend(Symbol(),OP_BUY,LotSize_Buy,Ask ,3,
                                             0,0,NULL,MagicNumber1,0,Green);RefreshRates();Sleep(500);
                                                if( OrderSelect(BuyTicketOrder1,SELECT_BY_TICKET)==true){
                                                      if(OrderSymbol() == Symbol() && OrderType() == OP_BUY )
                                                         bool ModifyBuy1 = OrderModify(BuyTicketOrder1,OrderOpenPrice(),BuyStopPrice,btp1,0,clrNONE);}
                                                
                                                
         BuyTicketOrder2 = OrderSend(Symbol(),OP_BUY,LotSize_Buy2,Ask ,3,
                                             0,0,NULL,MagicNumber1,0,Green);RefreshRates();Sleep(500);
                                                if( OrderSelect(BuyTicketOrder2,SELECT_BY_TICKET)==true){
                                                     if(OrderSymbol() == Symbol() && OrderType() == OP_BUY )
                                                        bool ModifyBuy2 = OrderModify(BuyTicketOrder2,OrderOpenPrice(),BuyStopPrice,btp2,0,clrNONE);}

...

Correct? 

 

Spot on honest knave, really appreciate it!

 Reading them now! Will post back the changes, thanks :) 

 
Only issue with this article ( Error 146 ("Trade context busy") and How to Deal with It ) here:

int _IsTradeAllowed(int MaxWaiting_sec = 30)
  {
    // check whether the trade context is free
    if(!IsTradeAllowed())
      {
        uint StartWaitingTime = GetTickCount();
        Print("Trade context is busy! Wait until it is free...");
        // infinite loop
        while(true)
          {
            // if the expert was terminated by the user, stop operation
            if(IsStopped()) 
              { 
                Print("The expert was terminated by the user!"); 
                return(-1); 
              }
            // if the waiting time exceeds the time specified in the 
            // MaxWaiting_sec variable, stop operation, as well
            if(GetTickCount() - StartWaitingTime > MaxWaiting_sec * 1000) // "sign mismatch" 
              {
                Print("The waiting limit exceeded (" ,MaxWaiting_sec, " сек.)!");
                return(-2);
              }

...

As GetTickCount() is not an accurate representation of time, how would I go about actually making sure a specific number of seconds has passed as a replacement if this highlighted if statement?

 

"Tick" is a misnomer... what GetTickCount actually records is the number of milliseconds since system start.

It does get filled up after ~50 days if the system isn't restarted.

GetTickCount()

Reason: