Vendrel
Vendrel

Reputation: 987

How to plot something if a Boolean value is TRUE? Pine Script V5

Here's my simplified code:

PlotOrNot = input.bool(true, title="Plot it", inline = "01")
plot(SomethingCalculated, "Calculated Thing", color=color.blue, offset = offset)

As I found here, there's a way to tell the plot command to do the plot in case the Boolean value is true but I could not manage to make it not turn into error messages.

Upvotes: 0

Views: 5224

Answers (1)

vitruvius
vitruvius

Reputation: 21199

Use it in the series argument of the plot().

plot(PlotOrNot ? SomethingCalculated : na, "Calculated Thing", color=color.blue, offset = offset)

Upvotes: 2

Related Questions