improve coding - simulating a fresh start of an indicator

 

Hi,


I have an indicator on the chart.

I want to be able to press a key on the chart, and this will simulate a restart of the indicator like it is drop on the chart for the first time.


Meaning:

I press a key on the chart (for ex: 'q').

this will call the DeInit function, and then the OnInit, and then the OnCalulate.


I succeeded doing this by simply calling the functions from the OnChartEvent function:

         OnDeinit(INIT_PARAMETERS_INCORRECT);  

         OnInit();   

         int Tempspread[];

         OnCalculate(Bars,0,Time,Open,High,Low,Close,Volume,Volume,Tempspread);                       


But this seems to me incorrect since those functions are high level functions.


Is there a function that can simulate this the correct way?



Thanks.









 
gfxlearner: simulate a restart of the indicator like it is drop on the chart for the first time.
Apply a template.
 
William Roeder #:
Apply a template.
ChartApplyTemplate


ChartApplyTemplate seems to be a solution for restart the indicator.


But I want to be able to change parameters of the indicator.


for ex':

There is an RSI(21) indicator on the chart.

I press a key on the chart (for ex: 'q').

and then the indicator is RSI(22).


any suggestion?




 
gfxlearner:

Hi,


I have an indicator on the chart.

I want to be able to press a key on the chart, and this will simulate a restart of the indicator like it is drop on the chart for the first time.


Meaning:

I press a key on the chart (for ex: 'q').

this will call the DeInit function, and then the OnInit, and then the OnCalulate.


I succeeded doing this by simply calling the functions from the OnChartEvent function:

         OnDeinit(INIT_PARAMETERS_INCORRECT);  

         OnInit();   

         int Tempspread[];

         OnCalculate(Bars,0,Time,Open,High,Low,Close,Volume,Volume,Tempspread);                       


But this seems to me incorrect since those functions are high level functions.


Is there a function that can simulate this the correct way?



Thanks.









Your initial logic is not incorrect, it works.