'Pinescript change plot display based on string options input

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)


Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user1071182