uint HowManyOrders(string   f_symbol="",  // instrument finansowy
                   int      f_cmd=-1,     // typ zlecenia
                   int      f_magic=-1,   // identyfikator
                   datetime f_openTime=0) // czas, po którym umieszczono zlecenia
  {
   uint f_total=0;
//---
   for(int i=OrdersTotal()-1; i>=0; i--)
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         int f_type=OrderType();
         if(f_type==OP_BUY || f_type==OP_SELL) continue;
         //---
         if((f_symbol==OrderSymbol()     || f_symbol=="") && 
            (f_cmd==OrderType()          || f_cmd==-1)    && 
            (f_magic==OrderMagicNumber() || f_magic==-1)  && 
            (f_openTime<=OrderOpenTime() || f_openTime==0))
            f_total++;
        }
//---
   return f_total;
  }