2
There are two types known as global.
- Those set with GlobalVariableSet will be saved on a orderly shutdown of the terminal and restored. (OS crash/power fail/etc. not reliable)
- Those defined outside of functions are initialized only once, on load. A shutdown/restart will reload to initial value. A deInit/init cycle will not reinitialize them.
double g = 1; int start() {..................................... if (...........) g = 2; return; }
In this case, if g has changed from 1 to 2, and then I shut down my computer.
now if I re open the platform, what should be the value of g?
Thank you!
WHRoeder:
There are two types known as global.
There are two types known as global.
- Those set with GlobalVariableSet will be saved on a orderly shutdown of the terminal and restored. (OS crash/power fail/etc. not reliable)
- Those defined outside of functions are initialized only once, on load. A shutdown/restart will reload to initial value. A deInit/init cycle will not reinitialize them.
Thanks WHRoeder. In my example, could you please tell me how could I set the value of "g" to be stored as 2, after my computer is shut down and restart?
zbleach:
In my example, could you please tell me how could I set the value of "g" to be stored as 2, after my computer is shut down and restart?
Use GlobalVariables
In my example, could you please tell me how could I set the value of "g" to be stored as 2, after my computer is shut down and restart?
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
Hi Pros,
Suppose in my EA, I set a global variable's initial value as 1, and after some condition happens it changes to 2.
Now I shut down my computer and then restart my computer and start the mt4 platform. Would the global variable be 1 or 2?
Thanks a lot!