Reputation: 1627
I'm trying to change which plots are displayed based on string options, but I'm getting the following error:
Add to Chart operation failed, reason: line 8: Invalid argument 'display' in 'plot' call. Possible values: [display.none, display.all]
//@version=5
// doesn't work
indicator("My script")
x = input.string(title="x", defval="one", options=["one","two"])
plot(close, display= x == "one" ? display.all : display.none)
// works
indicator("My script")
x = "one"
plot(close, display= x == "one" ? display.all : display.none)
Upvotes: 0
Views: 900
Reputation: 21121
If you change the color to na
you will not see it but the plot will still have a value.
Instead, you can apply your condition to the series
argument of the plot()
function. In this case, when your condition is false
plot will have na
.
//@version=5
indicator("My script")
x = input.string(title="x", defval="one", options=["one","two"])
c = x == "one" ? na : color.blue
p = x == "one"
plot(open, color=c) // Won't be visible but will still its value
plot(p ? close : na, color=color.white) // Will be na when false
Upvotes: 1
Reputation: 1627
Possible duplicate of
Is there a way to hide specific indicator values from the data window?
Changing display dynamically is not possible, but you can set color to na.
Upvotes: 0