How do I protect a variable from changing?
OK, it seems the trick is NOT to set the variable within OnInit().
I shall declare it and set it outside OnInit().
int TF = Period();
OK, it seems the trick is NOT to set the variable within OnInit().
I shall declare it and set it outside OnInit().
int TF = Period();
You agree to website policy and terms of use
In the code above, TF contains the output of Period(). Of course, it stands for "Timeframe".
My problem is, when I change the TF on the chart, OnInit() is run again and the TF changes accordingly.
What I want is for the variable to be evaluated only once, when the EA or indicator is loaded, and commit to that value forever.
How can I do that?