Events deinit -> init will inevitably be generated by the terminal when the timeframe changes.
https://www.mql5.com/en/docs/runtime/event_fire
Init #
Immediately after the client terminal loads a program (an Expert Advisor or custom indicator) and starts the process of initialization of global variables, the Init event will be sent, which will be processed by OnInit() event handler, if there is such. This event is also generated after a financial instrument and/or chart timeframe is changed, after a program is recompiled in MetaEditor, after input parameters are changed from the setup window of an Expert Advisor or a custom indicator. An Expert Advisor is also initialized after the account is changed. The Init event is not generated for scripts.
Deinit #
Before global variables are deinitialized and the program (Expert Advisor or custom indicator) is unloaded, the client terminal sends the Deinit event to the program. Deinit is also generated when the client terminal is closed, when a chart is closed, right before the security and/or timeframe is changed, at a successful program re-compilation, when input parameters are changed, and when account is changed.
The deinitialization reason can be obtained from the parameter, passed to the OnDeinit() function. The OnDeinit() function run is restricted to 2.5 seconds. If during this time the function hasn't been completed, then it is forcibly terminated. The Deinit event is not generated for scripts.
thank you All for your help.
i kept thinking maybe i was missing something.
thank you.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hello,
i have created a Semi Automated EA that gives me signals.
problem is that in the same time that my EA is Attached to 15Min charts in 8 different Currency Pairs, I need to keep changing the time Frames to Verify the signals.
and every time that i Change the time frame, EA Automaticly Deinits and swiftly Inits again in the new time frame, and i do not want that, because the global Variables starts fresh with value of zero.
i already know about the taskbar in MT4 : Tools > Options > Disable Automated Trading when the charts Symbol or Period Has Been Changed.
i turned that option off and still this problem exist.
i have searched the forum for an answer but i could not find any.
can anyone show me the way to stop the EA from Deinit and init again when period changes.
thank you in advance.