Vertical Lines linking Main- and Subchart(s)

In the threads treating the topic of vertical lines I didn't find the way
to get those which pass through main- and subcharts like does the
vertical line obtained by clicking on a candle.
So with the following code for exp. I only get vertical lines
which stop at the end of the main chart.

pr = Param( "ZigZag change amount", 0.236, 0.05, 20, 0.05 );
pk = PeakBars( H, pr ) == 0;
tr = TroughBars( L, pr ) == 0;
Plot( pk, "", colorRed, styleHistogram | styleOwnScale, 0, 1 );
Plot( tr, "", colorLightBlue, styleHistogram | styleOwnScale, 0, 1 );

You may simply apply the same code of your post in subchart(s) or you may store variables to static vars in main chart via StaticVarSet() and call those static vars in subchart(s) via StaticVarGet().

// main chart
pr = Param( "ZigZag change amount", 0.236, 0.05, 20, 0.05 );
pk = PeakBars( H, pr ) == 0;
tr = TroughBars( L, pr ) == 0;
Plot( pk, "", colorRed, styleHistogram | styleOwnScale, 0, 1 );
Plot( tr, "", colorLightBlue, styleHistogram | styleOwnScale, 0, 1 );
StaticVarSet("static_pk", pk);
StaticVarSet("static_tr", tr);
// "sub chart"
pk = StaticVarGet("static_pk");
tr = StaticVarGet("static_tr");
Plot( pk, "", colorRed, styleHistogram | styleOwnScale, 0, 1 );
Plot( tr, "", colorLightBlue, styleHistogram | styleOwnScale, 0, 1 );

You could also do like this

// main chart
pr = Param( "ZigZag change amount", 0.236, 0.05, 20, 0.05 );
StaticVarSet("static_pr", pr);

pk = PeakBars( H, pr ) == 0;
tr = TroughBars( L, pr ) == 0;
Plot( pk, "", colorRed, styleHistogram | styleOwnScale, 0, 1 );
Plot( tr, "", colorLightBlue, styleHistogram | styleOwnScale, 0, 1 );
// sub chart
pr = Nz(StaticVarGet("static_pr"), 0.236);
pk = PeakBars( H, pr ) == 0;
tr = TroughBars( L, pr ) == 0;
Plot( pk, "", colorRed, styleHistogram | styleOwnScale, 0, 1 );
Plot( tr, "", colorLightBlue, styleHistogram | styleOwnScale, 0, 1 );
1 Like

Thank you very much, that works indeed. The first solution seems
better as it reacts to modifications of the parameter in mainchart.
The desadvantage of both is just that it doesn't apply automatically
to the subcharts, but needs to be inserted in all of them.

But there is also an advantage of this method 'cause it's possible
to apply it the other way around to see where exactly signals
generated by the subchart occured by drawing the static vertical lines
on the mainchart...