bool IsPositionOpenedCurrentBar(ENUM_TIMEFRAMES f_timeFrame=PERIOD_CURRENT, // przedział czasowy
                                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 false;
//---
   for(int i=OrdersHistoryTotal()-1; i>=0; i--)
      if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
         if((f_symbol==OrderSymbol()      || f_symbol=="") &&
            (f_cmd   ==OrderType()        || f_cmd==-1)    &&
            (f_magic ==OrderMagicNumber() || f_magic==-1))
            if(OrderOpenTime()>=iTime(f_symbol,f_timeFrame,0))
               return true;
//---
   for(int j=OrdersTotal()-1; j>=0; j--)
      if(OrderSelect(j,SELECT_BY_POS,MODE_TRADES))
         if((f_symbol==OrderSymbol()      || f_symbol=="") &&
            (f_cmd   ==OrderType()        || f_cmd==-1)    &&
            (f_magic ==OrderMagicNumber() || f_magic==-1))
            if(OrderOpenTime()>=iTime(f_symbol,f_timeFrame,0))
               return true;
//---
   return false;
  }