I understand what you are saying about making the int static so it keeps its variable when the function is left, what I dont understand is how the "crossed" variable is counted down or up to 0 from -3,3.

Quote:
static int crossed = 0;
int Delay = 3;
if(crossOver(LP5,LP10))
crossed = Delay;
else if(crossUnder(LP5,LP10))
crossed = -Delay;

if(crossed > 0 && crossOver(RSI10,50)) {
enterLong();
crossed = 0;


The way I read that code is that crossed would become either 3 or -3 after completing the first if/else statement then the next part of the code looks to see if crossed is greater than 0 and the RSI has crossOver 50 from below. If crossed is greater ie (3) the algo goes long. Where does the count down actually take place? Shouldnt there be a loop statement somewhere to count the crossed variable down or up to 0?

Regards
TankWolf

Last edited by TankWolf; 09/25/12 08:58.