uint HowManyPositions(string f_symbol="",
int f_cmd=-1,
int f_magic=-1,
datetime f_openTime=0)
{
uint f_total=0;
for(int i=OrdersTotal()-1; i>=0; i--)
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
int f_type=OrderType();
if(f_type==OP_BUYLIMIT || f_type==OP_SELLLIMIT ||
f_type==OP_BUYSTOP || f_type==OP_SELLSTOP)
continue;
if((f_symbol==OrderSymbol() || f_symbol=="") &&
(f_cmd==OrderType() || f_cmd==-1) &&
(f_magic==OrderMagicNumber() || f_magic==-1) &&
(f_openTime<=OrderOpenTime() || f_openTime==0))
f_total++;
}
return f_total;
}