problem...not yet to finish delete the order!!! above script to take it?

 
Hi...

coming again need help and ask some question.. ^^

the scripts net yet finish delete the order, above script to execute!!
how can do the scripts wait to finish and turn the next return above?

example stoplevel=5, sell sellstoptotals 5 drop 1 to execute to delete sellstop, selllimit and buystop, problem buystop not yet to finish delete, above script to take it??

thanks

egt520

if(stoplevel > buystoptotals && 0 < buystoptotals + buylimittotals + selllimittotals)
{
         CleanAllPendings(magic,4); //delete BuyStop order
         CleanAllPendings(magic,2); //delete BuyLimit order
         CleanAllPendings(magic,5); //delete SellStop order
}
 
if(stoplevel > sellstoptotals && 0 < sellstoptotals + selllimittotals + buylimittotals)
{
         CleanAllPendings(magic,5); //delete SellStop order
         CleanAllPendings(magic,3); //delete SellLimit order
         CleanAllPendings(magic,4); //delete BuyStop order
}
 
void CleanAllPendings(int magic,int cmd)
{  
    for(int i=OrdersTotal()-1;i>=0;i--)
    {
      OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if ( OrderSymbol() != Symbol()) continue;
      if ( OrderMagicNumber() != magic) continue;
      if ( OrderType() != cmd) continue;
 
      int ticket = OrderDelete(OrderTicket(),CLR_NONE);
    }
    return(ticket);
}
 
More correctly it wiil be such
if(stoplevel > buystoptotals && 0 < buystoptotals + buylimittotals + selllimittotals)
{
         CleanAllPendings(magic,OP_BUYSTOP); //delete BuyStop order
         CleanAllPendings(magic,OP_BUYLIMIT); //delete BuyLimit order
         CleanAllPendings(magic,OP_SELLSTOP); //delete SellStop order
}
 
if(stoplevel > sellstoptotals && 0 < sellstoptotals + selllimittotals + buylimittotals)
{
         CleanAllPendings(magic,OP_SELLSTOP); //delete SellStop order
         CleanAllPendings(magic,OP_SELLLIMIT); //delete SellLimit order
         CleanAllPendings(magic,OP_BUYSTOP); //delete BuyStop order
}
 
void CleanAllPendings(int magicNumber,int cmd)
{  
    if (cmd==OP_BUY || cmd==OP_SELL) return;
    for(int i=OrdersTotal()-1;i>=0;i--)
    {
      OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if ( OrderSymbol() != Symbol()) continue;
      if ( OrderMagicNumber() != magicNumber) continue;
      if ( OrderType() != cmd) continue;
 
      bool ticket = OrderDelete(OrderTicket(),CLR_NONE);
    }
    return;
}
 
thanks Rosh. ^^

I've try to make my ea. but a lot want to ask and help again... ^^!

how to excute this same buytotals+buylimittotals, if drop -1 to execute?
 
         record totals                   if drop -1       
  if(buytotals + buylimittotals  > buytotals +buylimitotals )
    {
             execute
    } 


egt520
Причина обращения: