This program return numbers of winners (nWin)
from last accepted loss in current symbol :
// program global variable
double nWin;
void Profit() // Return nWin
{ datetime LastTimeLOSS=0;
j=0;
while ( j<OrdersHistoryTotal() )
{ if ( OrderSelect(j,SELECT_BY_POS,MODE_HISTORY) )
if ( OrderSymbol()==_Symbol )
if ( OrderType()==OP_BUY || OrderType()==OP_SELL )
{ if ( OrderCloseTime()>LastTimeLOSS && OrderProfit()<0.0 )
LastTimeLOSS=OrderCloseTime();
}
j++; }
if ( OrderSelect(0,SELECT_BY_POS,MODE_HISTORY) )
if ( LastTimeLOSS==0 ) LastTimeLOSS=OrderOpenTime();
else {}
else LastTimeLOSS=TimeCurrent();
j=0; CurrentPROFIT=0; nWin=0;
while ( j<OrdersHistoryTotal() )
{ if ( OrderSelect(j,SELECT_BY_POS,MODE_HISTORY) )
if ( OrderType()==OP_BUY || OrderType()==OP_SELL )
if ( ( OrderCloseTime()==LastTimeLOSS && OrderSymbol()!=_Symbol ) ||
OrderCloseTime()>LastTimeLOSS ) nWin++;
j++;
}
}