BEAWARE of OnDeinit() trap!

 

https://www.mql5.com/en/docs/runtime/event_fire desperately needs update.

Found a statement here:

https://www.mql5.com/en/book/applications/indicators_make/indicators_test


Attention! When testing indicators in the tester, the OnDeinit event does not work. 
Moreover, other finalization is not performed, for example, destructors of global objects are not called.


How would one know when an indicator stops/terminates in Tester ?
Good luck with that.
:(

Documentation on MQL5: MQL5 programs / Client Terminal Events
Documentation on MQL5: MQL5 programs / Client Terminal Events
  • www.mql5.com
Immediately after the client terminal loads a program (an Expert Advisor or custom indicator) and starts the process of initialization of global...
 
Soewono Effendi:

https://www.mql5.com/en/docs/runtime/event_fire desperately needs update.

Found a statement here:

https://www.mql5.com/en/book/applications/indicators_make/indicators_test



How would one know when an indicator stops/terminates in Tester ?
Good luck with that.
:(

you would not need that other than in an optimization though 

 
Soewono Effendi:

How would one know when an indicator stops/terminates in Tester ?

Good luck with that.
:(

You're right. Currently there is no way to catch this, and this is a flaw of MT5, but MQ thinks otherwise and did this deliberately (I will not go into details).

I suggested to call OnTester for indicators as it's for experts, because indicators can run in tester (and it makes sense to have a possibility to optimize them as well!), but that was not accepted.

 
A #property flag to indicate that OnDeinit() is required / necessary would be a great option.