ushort seriess[];
ushort series_current = 0;
input int magic=345461;
int NumberOfPositions(string sy="" , int mn=-1) {
int i, k=OrdersTotal(), kp=0;
if (sy=="0") sy=Symbol();
for (i=0; i<k; i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol()==sy || sy=="") {
if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
if(mn<0|| OrderMagicNumber()==magic) kp++;
}
}
}
}
return(kp);
}
void OnTick()
{
int count = NumberOfPositions(Symbol(),-1);
if(count == 0)
series_current = 0;
if(series_current != count)
{
series_current = (ushort)count;
if(count == 1)
seriess[0]++;
if(count > 1)
{
seriess[count-1]++;
seriess[count-2]--;
}
}
int i;
int k=12;
string comm;
string comm1;
for(i = 0; i < k; i++){
comm = StringConcatenate( "Серия из " , i );
comm1= StringConcatenate( "ордеров = ",seriess[i+1], "\n\r");
Comment(comm+comm1);
}