updating variables

 
In an EA, I am comparing prices to the three most recent peaks/valleys in price charts. I defined static variables because I want to maintain these values.

Whenever I identify a new peak or valley, i need to adjust the three most recent variables. I tried to to add this new value to my three variables and shift the previous data accordingly.

For example, when the condition for a new event is fulfilled, i programmed:

...
if ( ...)
{
variable_3 = variable_2;
variable_2 = variable_1;
variable_1 = iLow(Null,0,0) ;
}
...

Unfortunately, this does not seem to move the older data back into the next variable. The result is that all variables get the same value iLow(Null,0,0).

Does anyone know how to update variables and move the values accordingly?
 
Use Print function for debugging
 
Thank you! Problem solved - I had been working on tick level, so the variables were shifted every tick and of course all was overwritten. Limiting processing to the beginning of the bar solved the problem.
 
btw Slawa - any plans for a real debugger someday soon?

TIA,
m
 
May be in MT5.