Download MetaTrader 5

deinitialization function

To add comments, please log in or register
Thierry Ramaniraka
422
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
1162
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
422
Thierry Ramaniraka  
thank you.
whroeder1
18252
whroeder1  
Start using the new Event Handling Functions.
          Event Handling Functions - Functions - Language Basics - MQL4 Reference
Thierry Ramaniraka
422
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 ?

whroeder1
18252
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)
Thierry Ramaniraka
422
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.

To add comments, please log in or register