Indicator visualization

 
When I select specific timeframes for visualization in indicator properties, does it also stop the indicator from doing it's work for the remaining timeframe? Or is it that the indicator still works in the background, but the display is disabled?
 
highrise:
When I select specific timeframes for visualization in indicator properties, does it also stop the indicator from doing it's work for the remaining timeframe? Or is it that the indicator still works in the background, but the display is disabled?

Your question doesn't make sense. There is no "remaining timeframe." Most indicators have this form:

Start() { // A new tick.

...

for(int shift=...; shift >= 0; shift-- )

{

buffer[shift] = high[shift]-low[shift];

}

Compute the value, assign to the indicator's buffer, buffer gets displayed by mt4.

 
I understand what you mean. You mean when you select the time frames with the checkboxes in the properties screen. The answer is no, nothing executes in a time frame that is not selected.
 
circlesquares wrote >>
I understand what you mean. You mean when you select the time frames with the checkboxes in the properties screen. The answer is no, nothing executes in a time frame that is not selected.

Thanks. That was my understanding as well but what made me uncertain about this was I have couple of indicators that set global variables. I disable the visualization on certain timeframes. However, even when the chart is in this timeframe, when I delete the global variable file, it gets created immediately. I will do some more analysis to see what's happening.

 

Hi!


Is there a way to programatically specify which time frames an indicator is to be visible on? Kind of the equivalent of doing it manually through the properties window for the indicator ... I've only found a way to do it with objects on a chart, but not with indicators.


Thank you.


LINA

 

Hi!

I have similar issue here too! Is there a code to specify the visibility of the indicator in specific timeframe?

Thank you!

linalm:

Hi!


Is there a way to programatically specify which time frames an indicator is to be visible on? Kind of the equivalent of doing it manually through the properties window for the indicator ... I've only found a way to do it with objects on a chart, but not with indicators.


Thank you.


LINA

 
sgfxtrader:

Hi!

I have similar issue here too! Is there a code to specify the visibility of the indicator in specific timeframe?

Thank you!

lol... you lost me for a moment there :D

I have seen it (the visualization tab) but never noticed it. For an option, you can do a Period() filter in code manually and simply set DRAW_NONE from SetIndexStyle... if you like.

 
Avinash Singh:

Thanks. That was my understanding as well but what made me uncertain about this was I have couple of indicators that set global variables. I disable the visualization on certain timeframes. However, even when the chart is in this timeframe, when I delete the global variable file, it gets created immediately. I will do some more analysis to see what's happening.

The indicator does still run the initialize routine when set to not be visual, hence your global variable is still being created.

There is a simple way to identify if the visualization is off by setting a true/false condition that can be used to block other routines, as follows:

At the bottom of the parameters section (just above the init or OnInit section) then put the following line;

bool indicator_visual = false;

In the start or OnCalculate section, after all the checks that may prevent the indicator running, such as "If MA_period <1) return (0)" etc, then put the following line;

if (!indicator_visual) indicator_visual = true;

It works by Indicator_visual being false during initialization and then set to true during the first execution loop, so if that doesn't occur due to the visualization being off for a chosen time-frame or that an indicator setting is incorrect then it remains false.

It has just helped me solve a serious violation error as my indicator uses OnChartEvent to update itself when a line is moved and that routine was still running with visualization off and still trying to run parts of the indicator routines and kept causing read violations and crashing the indicator on certain time-frames where visualization was off, now it works perfectly with the OnChartEvent routines only being allowed to run if indicator_visual is true.

Reason: