Search code examples
pine-scriptmoving-average

How to Turn Off a plot by default in the Style window of a indicator in TradingView Pine Editor?


I have a custom script for Multiple EMA under a single indicator. Here's my sript:

//@version=4

//EMA
study("Multiple EMA", overlay=true)
plot(ema(close, 9), color = color.green, linewidth=2, title='9 EMA')
plot(ema(close, 18), color = color.red, linewidth=2, title='18 EMA')
plot(ema(close, 50), color = color.red, linewidth=2, title='50 EMA')
plot(ema(close, 100), color = color.red, linewidth=2, title='100 EMA')
plot(ema(close, 200), color = color.blue, linewidth=2, title='200 EMA')

I want to turn off/ uncheck the "9 EMA" and "18 EMA" plots from the "Style" window by default:

enter image description here

How can I achieve that using the Pine Editor?


Solution

  • The plot() function has an argument called display. You can set it to display.none so it will not be displayed initially.

    plot(ema(close, 9), color = color.green, linewidth=2, title='9 EMA', display=display.none)
    plot(ema(close, 18), color = color.red, linewidth=2, title='18 EMA', display=display.none)