In an expert adviser, in the OnTick() function, is there a way to set a global variable that will retain its value it had during the previous call? I'm looking for a variable that won't re-initialize with each new tick.
- My Bid price is not updating in my code
- Window handle
- Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes
theDUDE:
In an expert adviser, in the OnTick() function, is there a way to set a global variable that will retain its value it had during the previous call? I'm looking for a variable that won't re-initialize with each new tick.
In an expert adviser, in the OnTick() function, is there a way to set a global variable that will retain its value it had during the previous call? I'm looking for a variable that won't re-initialize with each new tick.
Hi theDUDE,
Come on, you can solve this yourself :), don't kidding around, we know you can solve this, it just a matter of coding.
In any EA, CI or Script:
double My_Var = 0.0; // this is set as global variable or static local variable OnTick() { if (My_Var == 0.0) My_Var = 1.618; //--- codes and codes goes here if (re_initialize == true) My_Vars = 0.0; // re-initialize again on next tick. }
click that delete link dude :)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register