📅  最后修改于: 2022-03-11 14:57:26.437000             🧑  作者: Mango
//+------------------------------------------------------------------+
//| 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);
}