deinitialization function

To add comments, please log in or register
Thierry Ramaniraka
542
Thierry Ramaniraka  
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.
Anthony Garot
3307
Anthony Garot  
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...
Thierry Ramaniraka
542
Thierry Ramaniraka  
thank you.
William Roeder
20236
William Roeder  
Start using the new Event Handling Functions.
          Event Handling Functions - Functions - Language Basics - MQL4 Reference
Thierry Ramaniraka
542
Thierry Ramaniraka  
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 ?

William Roeder
20236
William Roeder  

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)
Thierry Ramaniraka
542
Thierry Ramaniraka  
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.

MQLUsername
27
MQLUsername  
if i look to the MQL example indicators i can not see that OnDeinit() is used, why is it not used in MQL5 indicators?
Marco vd Heijden
Moderator
12736
Marco vd Heijden  
No but you can add it if you need it.
To add comments, please log in or register