Hello all
I am working on an EA and I noticed when I am using OnDeinit() in my EA , it causes the EA to shutdown by timeout upon manual removal of the EA from chart and sometimes it automatically restarts the Mt4 terminal
whereas when I am using the deinit() function in the same EA everything works fine.
why both of these functions have somewhat different behavior.
I know both these functions are called when the EA is deInitialized , and OnDeinit() is supposed to be the newer format but why does the EA behaves abnormally for OnDeinit() and not for the deinit() ?
can somebody please shed some light on this matter ?
PS: I dont have any code inside the deinitialization code block in both cases :
You should use OnDeinit it replaced deinit a long time ago.
make sure you have the latest version of MT4 and recompile.
why both of these functions have somewhat different behavior.
I know both these functions are called when the EA is deInitialized , and OnDeinit() is supposed to be the newer format but why does the EA behaves abnormally for OnDeinit() and not for the deinit() ?
can somebody please shed some light on this matter ?
PS: I dont have any code inside the deinitialization code block in both cases :
"deinit" is the old style code of MQL4 of yester-year and could be considered almost decrepit, while OnDeinit is the modern style MQL4+ code which makes it more compatible with MQL5.
However, your "freezing" is probably because your code (in the other sections) is probably not following the correct functionality of a more modern and stricter MQL4+ and is thus blocking the de-initialisation procedure.
You should stop using the old event handlers (init, start, deinit) and IndicatorCounted() and start using new event handlers (OnInit, OnTick/OnCalculate, OnDeinit).
Event Handling Functions - MQL4 Reference
How to do your lookbacks correctly - MQL4 programming forum #9-14 & #19 (2016)
- 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 all
I am working on an EA and I noticed when I am using OnDeinit() in my EA , it causes the EA to shutdown by timeout upon manual removal of the EA from chart and sometimes it automatically restarts the Mt4 terminal
whereas when I am using the deinit() function in the same EA everything works fine.
why both of these functions have somewhat different behavior.
I know both these functions are called when the EA is deInitialized , and OnDeinit() is supposed to be the newer format but why does the EA behaves abnormally for OnDeinit() and not for the deinit() ?
can somebody please shed some light on this matter ?
PS: I dont have any code inside the deinitialization code block in both cases :