Reputation: 987
Here are some plots in an indicator: several Thing 1s and several Thing 2s. We can enable/disable them, as usual. Elements to be grouped are marked with green and cyan colors for illustration purposes.
Goal is to group then up so we can enable/disable them by group, too, not just individually. (There's no reason to enable/disable any Thing 1/2s without enabling/disabling the other related elements.)
Code part is below the screenshot.
Kindle please give Version 4 and Version 5 syntax as well.
plot(thing1, "Thing 1", color=SomeColor, linewidth=6)
plot(thing1, "Thing 1", color=SomeColor, linewidth=9)
plot(thing1, "Thing 1", color=SomeColor, linewidth=4)
plot(thing1, "Thing 1", color=SomeColor, linewidth=3)
plot(thing1, "Thing 1", color=SomeColor, linewidth=2)
plot(thing1, "Thing 1", color=SomeColor2)
plot(thing2, "Thing 2", color=OtherColor, linewidth=6)
plot(thing2, "Thing 2", color=OtherColor, linewidth=9)
plot(thing2, "Thing 2", color=OtherColor, linewidth=4)
plot(thing2, "Thing 2", color=OtherColor, linewidth=3)
plot(thing2, "Thing 2", color=OtherColor, linewidth=2)
plot(thing2, "Thing 2", color=OtherColor2)
Upvotes: 0
Views: 831
Reputation: 8779
You need to plot conditionally using a user input. Users will make their selection from the "Settings/Inputs" tab instead of the "Settings/Style" tab. This code implements the exclusive logic you mention, but you could also provide one user choice for each plot and adjust your plotting conditions accordingly:
//@version=5
indicator("")
showThing1Input = input(true, "Show Thing 1")
SomeColor = color.green
SomeColor2 = color.lime
OtherColor = color.red
OtherColor2 = color.fuchsia
thing1 = 1
thing2 = 2
plot(showThing1Input ? thing1 : na, "Thing 1", color=SomeColor, linewidth=6)
plot(showThing1Input ? thing1 : na, "Thing 1", color=SomeColor, linewidth=9)
plot(showThing1Input ? thing1 : na, "Thing 1", color=SomeColor, linewidth=4)
plot(showThing1Input ? thing1 : na, "Thing 1", color=SomeColor, linewidth=3)
plot(showThing1Input ? thing1 : na, "Thing 1", color=SomeColor, linewidth=2)
plot(showThing1Input ? thing1 : na, "Thing 1", color=SomeColor2)
plot(not showThing1Input ? thing2 : na, "Thing 2", color=OtherColor, linewidth=6)
plot(not showThing1Input ? thing2 : na, "Thing 2", color=OtherColor, linewidth=9)
plot(not showThing1Input ? thing2 : na, "Thing 2", color=OtherColor, linewidth=4)
plot(not showThing1Input ? thing2 : na, "Thing 2", color=OtherColor, linewidth=3)
plot(not showThing1Input ? thing2 : na, "Thing 2", color=OtherColor, linewidth=2)
plot(not showThing1Input ? thing2 : na, "Thing 2", color=OtherColor2)
Upvotes: 1