Here are a few examples of how to show or hide sections of plots in ThinkScript, mainly using IsNaN(). There are other ways to limit plots, of course, but these are the basic methods I usually use. Anyone else, please feel free to post additional ways.
Plotting only on a single price bar -
Plotting only in a certain defined area -
Plotting from a defined point and continuing left -
Plotting from a defined point and continuing right -
Plotting a certain distance into the expansion area -
Hope this helps!
Plotting only on a single price bar -
Code:
plot a = !isnan(close[-5]) and isnan(close[-6]);
a.setpaintingstrategy(paintingstrategy.boolean_arrow_up);
a.setdefaultcolor(color.cyan);
Plotting only in a certain defined area -
Code:
plot b = !isnan(close[-11]) and isnan(close[-17]);
b.setpaintingstrategy(paintingstrategy.boolean_arrow_up);
b.setdefaultcolor(color.cyan);
Plotting from a defined point and continuing left -
Code:
plot c = !isnan(close[-20]);
c.setpaintingstrategy(paintingstrategy.boolean_arrow_up);
c.setdefaultcolor(color.cyan);
Plotting from a defined point and continuing right -
Code:
plot d = isnan(close[-50]);
d.setpaintingstrategy(paintingstrategy.boolean_arrow_up);
d.setdefaultcolor(color.cyan);
Plotting a certain distance into the expansion area -
Code:
input plot_line_here = 55;
input length_of_line = 5;
def x = !isnan(close) && isnan(close[-1]);
plot e = if isnan(close) and barnumber() <= HighestAll(if x then barnumber() + length_of_line else double.nan) then plot_line_here else double.nan;
e.setpaintingstrategy(paintingstrategy.horizontal);
e.setdefaultcolor(color.cyan);
Hope this helps!