This forum is in read-only mode now. You may discuss your questions on forums of MQL4.community and MQL5.community

updating variables


Back to topics list
avatar
85
bubo 2006.12.30 16:37 
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?
avatar
4464
Slawa 2007.01.08 13:12 
Use Print function for debugging
avatar
85
bubo 2007.01.08 22:56 
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.
avatar
17
m88 2007.01.17 09:07 

btw Slawa - any plans for a real debugger someday soon?

TIA,
m
avatar
4464
Slawa 2007.01.17 10:30 
May be in MT5.
Back to topics list  
Download MetaTrader 5 (450 Kb, web installer) — a new terminal for financial markets