deinitialization function

 
Hello,
As I constantly feed my MQL knowledge, I ask you the difference between theese 2 "deinitialization functions" :
int deinit()
//or
void OnDeinit(const int reason)
It seems that both do the job. What is the "better way" to deinitialize ?

Regards.
 
Thierry Ramaniraka:
Hello,
As I constantly feed my MQL knowledge, I ask you the difference between theese 2 "deinitialization functions" :
It seems that both do the job. What is the "better way" to deinitialize ?

Regards.
https://www.mql5.com/en/forum/213549
what is the diff between : init() deinit() start() vs OnInit() OnDeinit() OnTick()
what is the diff between : init() deinit() start() vs OnInit() OnDeinit() OnTick()
  • 2017.08.15
  • www.mql5.com
what is the diff between : init() deinit() start() vs OnInit() OnDeinit() OnTick() ?? tks...
 
thank you.
 
Start using the new Event Handling Functions.
          Event Handling Functions - Functions - Language Basics - MQL4 Reference
 
whroeder1:
Start using the new Event Handling Functions.
          Event Handling Functions - Functions - Language Basics - MQL4 Reference

Hello,
My problem is when I use the classic "deinit" with a button in it to delete it, if i dleete the indicator, each time I change the time frame my button change it's state.
What Event function can make my button keep it's state even if i change the time frame ?

 

Classic or new are identical. It is you that are deleting and recreating your button, thus loosing state.

  1. You are changing TFs, everything should be reset.

  2. No reason to remove the button if the reason if Uninitialization Reason Code is REASON_CHARTCHANGE. Just check if the button already exists before creating it.

  3. For EAs, just remember the state and use it for recreating. For indicators, save the state in persistent storage (GV or files)
 
whroeder1:

Classic or new are identical. It is you that are deleting and recreating your button, thus loosing state.

  1. You are changing TFs, everything should be reset.

  2. No reason to remove the button if the reason if Uninitialization Reason Code is REASON_CHARTCHANGE. Just check if the button already exists before creating it.

  3. For EAs, just remember the state and use it for recreating. For indicators, save the state in persistent storage (GV or files)

Ok, thank you very much.

 
if i look to the MQL example indicators i can not see that OnDeinit() is used, why is it not used in MQL5 indicators?
 
No but you can add it if you need it.