- docs.mql4.com
The OnDeinit() function (https://docs.mql4.com/basis/function/events) takes in a parameter that tells your code the reason for de-initialization. So you can check that if it is called due to chart TF change, set a flag such that when your OnInit() runs again, it won't pop up the message box.
Thanks Seng Joo Thio,
That was perfect.
How to save that value while EA is restarting and losing it's collected values?
I have 2 ideas for it but I also want to know if you have a better idea.
I can write this value down on a csv file or use a terminal global variable.
Is it the right way?
Thanks Seng Joo Thio,
That was perfect.
How to save that value while EA is restarting and losing it's collected values?
I have 2 ideas for it but I also want to know if you have a better idea.
I can write this value down on a csv file or use a terminal global variable.
Is it the right way?
You can use any global variable - they don't get re-initialized when the chart's timeframe changes.
Another way is to forget about using any flag/variable... just call UninitializeReason() in OnInit() to find out whether it is a cold start, and if not, the reason for restarting... (according to https://docs.mql4.com/constants/namedconstants/uninit).- docs.mql4.com
You can use any global variable - they don't get re-initialized when the chart's timeframe changes.
Another way is to forget about using any flag/variable... just call UninitializeReason() in OnInit() to find out whether it is a cold start, and if not, the reason for restarting... (according to https://docs.mql4.com/constants/namedconstants/uninit).Thanks a lot Seng Joo Thio
Perfect.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I noticed that with every manual change of time-frame EA is restarting.
Sometimes it makes some difficulties for me.
In the project I'm currently working on, every time user runs the EA some conditions have to be in checked OnInit() and if necessary, a message box will appear to give him a warning.
If user decide to continue using the EA with the same setting, then,It becomes annoying when he sees the same message box with every time-frame changing.
The same thing is happening when he changes some other parameters in the parameters window and press OK, but this is more acceptable.
Please let me know if there is a way to solve this problem.
Thanks