How can i call a function when the chart or MT5 closes ?

 

I use MT5 to develop a EA.

In MT5 there can be a number of charts active which will all run their each EA.

I would like to write the last state of the EA into a separate file for each symbol (chart).

What I can’t figure out how to catch a close chart event or close MT5 ?

If one of them occur they should all write their status into their respectively files ( also come handy for ObjectsDeleteAll() ).

 

My question, how do I catch a close chart and close MT5 event in my EA? 

I have put a breakpoint in void OnDeinit , but here it wont come.



  

Thank you

 
defstut: What I can’t figure out how to catch a close chart event or close MT5 ?=

OnDeinit.

 
If that's the case why doesn't it stop on breakpoint in OnDeinit? 
History debug or debug on real data makes no difference ...