📜  其他“ CountPositions(sym) ” - 任何代码示例

📅  最后修改于: 2022-03-11 14:57:26.437000             🧑  作者: Mango

代码示例1
//+------------------------------------------------------------------+
//|     CountPositions(sym)                                          |
//+------------------------------------------------------------------+
int CountPositions(string sym)
  {
   int count = 0;
   double profit = 0;
   for(int i=PositionsTotal()-1; i>=0; i--)
      if(m_position.SelectByIndex(i)) // selects the position by index for further access to its properties
         if(m_position.Symbol()==sym)
            if(m_position.Magic()==iMagicNumber)
               if(m_position.Type() == POSITION_TYPE_BUY || m_position.Type() == POSITION_TYPE_SELL)
                 {
                  count++;
                 }

   return (count);
  }