Call or Pass common parameter(s) from one Pane/Indicator to other

Let’s assume, apart from the Price chart pane we have two more indicator panes inserted in a single chart:

Pane 1 holding CCI(14)

periods = Param( "Periods", 14, 2, 200, 1 );
Plot( CCI( periods ), _DEFAULT_NAME(), colorWhite, ParamStyle("Style")  );

Pane 2 holding RSI(14)

periods = Param("Periods", 14, 1, 200, 1 );
Plot( RSIa( P, periods), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style")  );

Now, if we have to change the common parameter “periods” value to, let’s say 21 for both the indicators, then, we have to right click on each pane and change it twice.

How do I refrain from this effort duplication?

Many thanks in advance!

One way is to write them both into the same AFL, using a parameter and condition to display each one in a separate pane. Then insert the code twice to the chart and alter the display parameter for each. It’s described in detail on this thread: Plotting two custom indicators of same AFL into two different panes

You can then have a single parameter that is used as the input period in both cases.

The mentioned link shows on how to switch between indicators using param. Thanks! But that’s not what I looking for.

How to mirror the “one” change made in parameter value of Pane 1 be reflected onto Pane 2 (without going there)?

P.S. The above CCI, RSI example is a simplified version of a monster that I dealing with.

You can use static variable. In one pane define the parameter you want to share

// Pane 1
periods = Param("periods", 10, 1, 100 );
StaticVarSet("sharedparam", periods  );
Plot( CCI( periods ), _DEFAULT_NAME(), colorWhite, ParamStyle("Style")  );

in second pane just read the static variable

periods  = StaticVarGet("sharedparam");
// use periods 
Plot( RSI( periods ), _DEFAULT_NAME(), colorWhite, ParamStyle("Style")  );
RequestTimedRefresh( 1 ); 

This way you can share any number of parameters between any number of charts. Note that “sharedparam” is a global static variable visible from everywhere, so make sure it is unique for what you want to share.

2 Likes

Appreciate your kind help. Thank you very much!

1 Like