'Display plot on intraday only

Pine Script question:

I want to display a 9ema plot on intraday charts only. When I use this code:

//@version=4

ema9 = ema(close, 9)
plot(ema9, '9ema', color.white, 2, display = iff(timeframe.isintraday, display.all, display.none))

I get "Cannot call 'plot' with 'display'=integer. The argument should be of type: const integer"

The documentation states that display.all and display.none are const integer. What am I missing?



Solution 1:[1]

you can use this code to display the ema on intraday charts. In this I have returned plot value only if chart is intraday other wise "na" is returned which wont plot anything.

ema9 = ema(close, 9)
plot(timeframe.isintraday?ema9:na, title='9ema', color=color.white, linewidth=2)

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 badshah_e_alam