Здравствуйте! Если не трудно, помогите реализовать ограничение количества открываемых ордеров в следующем коде:

 
double opB=200; double opS=0; double orderProfitbuy=0; double Sum_Profitbuy=0 ; double orderProfitsel;  double Sum_Profitsel ; int orderType ;
double LotB=Lot;
double LotS=Lot;
   int total=OrdersTotal();
   int b=0,s=0, n=0;
   for (int i=total-1; i>=0; i--)
   {if(OrderSelect(i, SELECT_BY_POS))
   {if(OrderSymbol()==Symbol()      )
   {n++;    
      if (OrderType()==OP_BUY &&OrderMagicNumber()==Magic)
      {b++; 
      LotB=OrderLots();      
      int tikketB=OrderTicket(); double ProfitB=OrderTakeProfit(); double openB=OrderOpenPrice();
      if (openB<opB)
      {opB=openB;}
      }
//---------------------------------      
      if (OrderType()==OP_SELL&&OrderMagicNumber()==Magic)
      {s++;  
      LotS=OrderLots(); 
      int tikketS=OrderTicket(); double ProfitS=OrderTakeProfit(); double openS=OrderOpenPrice();
      if (openS>opS)
      {opS=openS;}
      }
 

Кнопка для вставки кода! SRC