0

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)
user1071182
  • 1,609
  • 3
  • 20
  • 28

2 Answers2

1

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
vitruvius
  • 15,740
  • 3
  • 16
  • 26
0

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.

user1071182
  • 1,609
  • 3
  • 20
  • 28