double GetSumProfitOpenedPositions(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 DBL_MAX;
//---
   double f_sumProfit=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_sumProfit+=OrderProfit();
            f_isPositionExist=true;
           }
//---
   if(f_isPositionExist) return f_sumProfit;
   else return DBL_MAX;
  }