int GetSumPipsOpenedPositions(string f_symbol="", // instrument finansowy
                              int    f_cmd=-1,    // typ pozycji
                              int    f_magic=-1)  // identyfikator
  {
   if(f_cmd==OP_BUYLIMIT || f_cmd==OP_SELLLIMIT ||
      f_cmd==OP_BUYSTOP  || f_cmd==OP_SELLSTOP)
      return INT_MAX;
//---
   int  f_sumPips=0;
   bool f_isPositionExist=false;
   for(int i=OrdersTotal()-1; i>=0; i--)
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
         if((f_symbol==OrderSymbol()      || f_symbol=="") &&
            (f_cmd   ==OrderType()        || f_cmd==-1) &&
            (f_magic ==OrderMagicNumber() || f_magic==-1))
           {
            f_isPositionExist=true;
            if(OrderType()==OP_BUY)
               f_sumPips+=int((MarketInfo(OrderSymbol(),MODE_BID)-OrderOpenPrice())*
                              MathPow(10,MarketInfo(OrderSymbol(),MODE_DIGITS)));
            if(OrderType()==OP_SELL)
               f_sumPips+=int((OrderOpenPrice()-MarketInfo(OrderSymbol(),MODE_ASK))*
                              MathPow(10,MarketInfo(OrderSymbol(),MODE_DIGITS)));
           }
//---
   if(f_isPositionExist) return f_sumPips;
   else return INT_MAX;
  }