Indicators - Stop variable being re-initialised...

 

Hi. Apparently simple question but I'm baffled. With Indicators, how do you prevent a Globally declared variable from being re-initialised when the user changes a setting? Also, why are Global variables NOT re-initialised in EA's??? I'm hoping there's a better option than having to save a single byte to a file........

 

I think you can use UnitializeReason() in the init() function telling you why it's now init-ed...

 
ralph.ronnquist:
I think you can use UnitializeReason() in the init() function telling you why it's now init-ed...

I appreciate the response.

Unfortunately, I don't think this can help me. All I am trying to do is prevent a Globally declared variable from being reset to zero when a user setting is changed. As far as I'm aware, global variables are initialised before the Init() function is called, and the UnitialiseReason() will only tell me the reason for the interruption. Plus, as I mentioned, in EAs, global variables are not reset to zero when a user-setting is changed. I was hoping there was another class of variable available for this. Static Int seemed the most likely solution but it gets reset too....

 

In case anyone experiences similar problems, the (obvious) way to prevent variables being re-initialised is to use the Global variable commands - GlobalVariableCheck, GlobalVariableGet etc. - I completely forgot about those...... Doh!

Doesn't really solve my problem as I also have arrays with variable numbers of elements which also are re-set and will need to be written to a file to preserve them.....

Therefore, especially as this problem does not occur with EAs, I would conclude that this sould be classed as another bug that Metaquotes should fix.

Reason: