仅在当年的 Pinescript 中绘制线条

plot line only in the current year in Pinescript

我正在为 tradingview 做一个指标,我只想绘制当年的结果...

e = ema(close, 21)
plot(e)

我想要的是这样的:

plot( is_current_year ? e : na )

我会使用类似的东西:

//@version=3
study("Plot current year")

isCurrentYear = year(timenow) == year(time)
plot(isCurrentYear ? close : na)