Dynamic version of indicator_levelN

 

Is there a run-time function of indicator_levelN property?

My indicator needs level set only if one of the input parameters is set to a specific value.

Is there any way to add or remove a separate window level during run-time?

Or is there any reasonable way to add such level using graphical objects?

 
enivid:

Is there a run-time function of indicator_levelN property?

My indicator needs level set only if one of the input parameters is set to a specific value.

Is there any way to add or remove a separate window level during run-time?

Or is there any reasonable way to add such level using graphical objects?

Don't use property directive then, use IndicatorSet... funtions (IndicatorSetDoubleIndicatorSetInteger , IndicatorSetString with their Custom Indicator Properties). but we still have to tell compiler that the indicator is for main or separate/sub chart using #property and we can not change it on the fly :(.

In you case :

1. To dynamically set indicator level N property, use first IndicatorSetInteger with properties such as INDICATOR_LEVELS, (and also only if you want INDICATOR_LEVELCOLOR, INDICATOR_LEVELSTYLE, INDICATOR_LEVELWIDTH), and then set the level with IndicatorSetDouble with INDICATOR_LEVELVALUE.

2. We cannot change indicator from main chart to separate chart without changing #property (did I said that before ?), but if what you mean was changing max and min value of indicator separate windows, then use IndicatorSetDouble with INDICATOR_MINIMUM and INDICATOR_MAXIMUM.

You can set all of this inside OnInit or OnCalculate. 

3. If you're in doubt ... think. Yes you can use Object Functions. To find which window to draw the objects, do this : make sure that you are already give a short name to your indicator, using IndicatorSetString with INDICATOR_SHORTNAME property. Later you can use ChartWindowFind to find the window the indicator is attached, and then draw the objects.

 

 
phi.nuts:

Don't use property directive then, use IndicatorSet... funtions (IndicatorSetDoubleIndicatorSetInteger , IndicatorSetString with their Custom Indicator Properties). but we still have to tell compiler that the indicator is for main or separate/sub chart using #property and we can not change it on the fly :(.

In you case :

1. To dynamically set indicator level N property, use first IndicatorSetInteger with properties such as INDICATOR_LEVELS, (and also only if you want INDICATOR_LEVELCOLOR, INDICATOR_LEVELSTYLE, INDICATOR_LEVELWIDTH), and then set the level with IndicatorSetDouble with INDICATOR_LEVELVALUE.

2. We cannot change indicator from main chart to separate chart without changing #property (did I said that before ?), but if what you mean was changing max and min value of indicator separate windows, then use IndicatorSetDouble with INDICATOR_MINIMUM and INDICATOR_MAXIMUM.

You can set all of this inside OnInit or OnCalculate. 

3. If you're in doubt ... think. Yes you can use Object Functions. To find which window to draw the objects, do this : make sure that you are already give a short name to your indicator, using IndicatorSetString with INDICATOR_SHORTNAME property. Later you can use ChartWindowFind to find the window the indicator is attached, and then draw the objects.

 

Thank you very much! Don't know how I overlooked the IndicatorSet... functions.