Can indicator visualization properties be set programatically?

 

Hi Everyone

I need an indicator to be displayed only on specified timeframe. Currently I have to do it manually by setting visualization property.

Is there a way I can do it programmatically?

Thanks in advance.

Update: ........................

From one of the forum's post I got the following solution:-

int OnCalculate(const int                               rates_total,
                const int                               prev_calculated,
                const datetime          &time[],
                const double                    &open[],
                const double                    &high[],
                const double                    &low[],
                const double                    &close[],
                const long                              &tick_volume[],
                const long                              &volume[],
                const int                               &spread[]) {
  //+---------------------------------------------------------------------------------------------------------------------------+
  //| RUN THE INDICATOR ONLY ON CHART EXCLUDING (PERIOD_M1 and PERIOD_M5)
  //+---------------------------------------------------------------------------------------------------------------------------+
                if(_Period == PERIOD_M1 || _Period == PERIOD_M5)                        return(0);

Is does work as expected by not displaying the indicator on specified chart(s).

However I am not sure its effect on the performance or resources utilization as it is in OnCalculate() of the indicator. I would prefer a solution in OnInit() so it runs once or at each time when the time frame is changed.

Regards

 
Anil Varma:

Hi Everyone

I need an indicator to be displayed only on specified timeframe. Currently I have to do it manually by setting visualization property.

Is there a way I can do it programmatically?

Thanks in advance.

Update: ........................

From one of the forum's post I got the following solution:-

Is does work as expected by not displaying the indicator on specified chart(s).

However I am not sure its effect on the performance or resources utilization as it is in OnCalculate() of the indicator. I would prefer a solution in OnInit() so it runs once or at each time when the time frame is changed.

Regards

In OnInit, you can prevent the loading of the indicator by returning some other than INIT_SUCESS.




 
Dominik Christian Egert #:
In OnInit, you can prevent the loading of the indicator by returning some other than INIT_SUCESS.




Thanks @Dominik Christian Egert

It seems working :)

Will monitor for some time and revert if found any issue.
 
Dominik Christian Egert #:
In OnInit, you can prevent the loading of the indicator by returning some other than INIT_SUCESS.




That's not exact. The indicator will still be loaded and on the chart, but no event handlers will be executed.
 
Anil Varma:

Hi Everyone

I need an indicator to be displayed only on specified timeframe. Currently I have to do it manually by setting visualization property.

Is there a way I can do it programmatically?

Thanks in advance.

Update: ........................

From one of the forum's post I got the following solution:-

Is does work as expected by not displaying the indicator on specified chart(s).

However I am not sure its effect on the performance or resources utilization as it is in OnCalculate() of the indicator. I would prefer a solution in OnInit() so it runs once or at each time when the time frame is changed.

Regards

It's not possible to set an indicator visualization timeframes by code.
 
Alain Verleyen #:
It's not possible to set an indicator visualization timeframes by code.

Thanks  @Alain Verleyen for confirmation.

 
Alain Verleyen #:
That's not exact. The indicator will still be loaded and on the chart, but no event handlers will be executed.
Thank you for checking and letting me know.



Reason: