What really happens when Mt4 closes and opens? (fixed)

 

Good night everyone,

I have a little problem with one of my indicators. It works fine when just loaded, in real time and in visual backtests. However, when MT4 closes and opens restoring the charts previously opened, the indicator goes nuts and one buffer (the last one) is always storing EMPTY_VALUE instead of the asigned value. I reset every variable on the init() function, so I am a bit lost. How can I make the indicator to truly reload when Mt4 reopens? I would like to know what MT4 does when it reopens after closing. Thanks!

 
  1. You fix the indicator. It is broken.
  2. There should be no variables in init requiring a reset. (Possibly a reset when indicatorCounted returns zero)
  3. No mind readers here - post the code.
 
flaab:

Good night everyone,

I have a little problem with one of my indicators. It works fine when just loaded, in real time and in visual backtests. However, when MT4 closes and opens restoring the charts previously opened, the indicator goes nuts and one buffer (the last one) is always storing EMPTY_VALUE instead of the asigned value. I reset every variable on the init() function, so I am a bit lost. How can I make the indicator to truly reload when Mt4 reopens? I would like to know what MT4 does when it reopens after closing. Thanks!

Perhaps it is not your case, but it may happen if you use account related functions or variables in the init() - e.g. MarketInfo(), Ask, Digits, AccountNumber(). Use them later within the first run of start().

Reason: