Qw3rty,

I must concede I don't fully understand what you are trying to do. But when I look at your for(closed_trades), and you want Count to be reset to 1 and stay there, you might want to add a break statement:

Code
for(closed_trades) {
    if (crossOver(SMA30,SMA100)) {
        Count++;
    } else if (crossUnder(SMA30,SMA100)) {
        Count = 1;
        break_trades;	// to prevent the loop from keeping on counting up
    }
}


But then, wouldn't it be more straightforward to re-shuffle like this, since the loop does not affect the result of the if conditions:

Code
if (crossOver(SMA30,SMA100)) {
    for(closed_trades) {
        Count++;   // Or count this elsewhere to avoid the loop
    }
} else if (crossUnder(SMA30,SMA100)) {
    Count = 1;
}


Again, with the caveat that your intention isn't entirely clear to me...