Code to show / hide plots

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
biffhero
Posts: 47
Joined: 22 Sep 2020
Has thanked: 29 times
Been thanked: 6 times

Code to show / hide plots

Postby biffhero » 20 Jul 2021

A friend was explaining to me how TOS made enabling and disabling charts really easy. And how it was easier in MC than in TS. Well, this was "This is the sort of thing up with which I could not put." Shout out to Jeremy for being The Unreasonable Man https://www.goodreads.com/quotes/536961 ... reasonable on "enabling plots sucks".

Usage: change plotsToShow and maxPlotCount as needed

Code: Select all

Inputs: plotsToShow(7), maxPlotCount(3); Variables: j(0), plotDivisor(0), plotsDesired(0), plotsRemaining(0), plotVisible(0); plotsDesired = plotsToShow; plotsRemaining = plotsDesired; for j = maxPlotCount downTo 1 begin // This works on powers of two. // // plot 1 --> 2^1 = 1 // plot 2 --> 2^2 = 2 // plot 3 --> 2^3 = 4 // plot 4 --> 2^4 = 8 // // To display plots, add up the power values // // | plots shown | total | // |-------------+-------| // | 1 | 1 | // | 2 | 2 | // | 3 | 4 | // | 4 | 8 | // | 1, 2 | 3 | // | 1, 3 | 5 | // | 1, 2, 3 | 7 | // | 1, 2, 3, 4 | 15 | // plotDivisor = (power(2, (j - 1))); plotVisible = (plotsRemaining / plotDivisor); if (plotVisible >= 1) then begin plotsRemaining = plotsRemaining - plotDivisor; end else begin noPlot(j); end; end;

Return to “User Contributed Studies and Indicator Library”