Download MetaTrader 5

ChartSetSymbolPeriod maybe problem?

To add comments, please log in or register
fly7680
698
fly7680  

Hi everyone, I do not understand why using this feature,

ChartSetSymbolPeriod();

my indicator is deinitialized and initialized each time I change symbol. How can I overcome this problem?

thank you

Marco vd Heijden
Moderator
5948
Marco vd Heijden  

By not changing symbol.

fly7680
698
fly7680  
Marco vd Heijden:

By not changing symbol.

Thank you for your answer! Do you want to tell me that this function works so and I can not do anything?
Marco vd Heijden
Moderator
5948
Marco vd Heijden  

This function works so.

You would have to find another solution.

Stuart Browne
6789
Stuart Browne  

Your indicator will de-init and re-init every time either the symbol or timeframe changes, manually or through code. You can capture the event by checking the reason in OnDeinit (looking for REASON_CHARTCHANGE). 

I'm assuming it is causing you trouble as certain indicator values are resetting when it re-inits? If that's the case, save values to globals and read them back in in OnInit. I have to do this in quite a lot of my indicators/EAs

fly7680
698
fly7680  
Thanks to everyone for the answers, now it's all clear and I can study a possible solution! My problem is that I can not recompile each time the code if I change Time Frame or period, I have alarms that would play again without reason.
To add comments, please log in or register