how to get total of each buy/sellstop/limit?

 
mean OP_BUYSTOP always stay at 4 order, if miss one of OP_BUYSTOP order, delete and order again all pending order. no of OP_BUY

have any guide to teach me.
i am the begining. newbie ^^|

thanks

tytian
 
  int BuyCnt = 0;
  int SellCnt = 0;
  int BuyStopCnt = 0;
  int SellStopCnt = 0;
  int BuyLimitCnt = 0;
  int SellLimitCnt = 0;
  
  int cnt = OrdersTotal();
  for (i=0; i < cnt; i++) 
  {
    if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
    if (OrderSymbol() != Symbol()) continue;
   
    int type = OrderType();
    if (type == OP_BUY) BuyCnt++;
    if (type == OP_SELL) SellCnt++;
    if (type == OP_BUYSTOP) BuyStopCnt++;
    if (type == OP_SELLSTOP) SellStopCnt++;
    if (type == OP_BUYLIMIT) BuyLimitCnt++;
    if (type == OP_SELLLIMIT) SellLimitCnt++;
  }
 
many thanks RickD.

and again, how from the totals drop -1 to execute it, RickD?

example
6 (buy set 6) + 6 (buylimit set 6) totals and take 1 (buystop set = 4)
buy 6 + buylimit 6 + buystop 1= the all total become 13 not 12!
how i from here -1 to execute?

say thanks

egt520
 
   for (int i=OrdersTotal()-1;i>=0;i--)
      {
      if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
         {
         if (OrderMagicNumber()==magicNumber && OrderSymbol()==Symbol())
         {/*execute*/}
         }
      }
Reason: