OnDeinit Asynchronous ?

 

Hi,

using indicators i noted a weird stuff: when i switch period, the OnInit of new period is called before OnDeinit of prev period... 

How it is possible? Is OnDeinit call asynchronous?

 
antony23: How it is possible? 

It's not.

 

In switching period it happens randomically, but if i close chart and imemdiately reopen the same symbol, it always happens!

Simple to replicate... using Print() on init and deinit.

Maybe in my case it is most noticeble because in my deinit i use objectdeleAll and i have a lot of objects, so it keeps more time.

 
William Roeder:

It's not.

should not could be the right answer.

Try switching fast between periods, it happens!

If you switch slowly periods, and if you close chart and wait some seconds before re-open same symbol, it does not happen because we wait the "right time" for deinit to end.


Is it a BUG or it works (badly) so?

Documentation on MQL5: Chart Operations / ChartClose
Documentation on MQL5: Chart Operations / ChartClose
  • www.mql5.com
ChartClose - Chart Operations - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

OK, i found this thread: https://www.mql5.com/en/forum/160715

It was already discussed, 4 years from it, and no fix! GREAT MQ!

OnDeinit() race condition and recalculation issues
OnDeinit() race condition and recalculation issues
  • 2016.11.13
  • www.mql5.com
Hello, I am writing an indicator which draws certain objects in the chart...