如何在 Pine Script 中填充不同分辨率数据的图?

How to fill plots on different resolution data in Pine Script?

我想在 2 个地块之间填充。当图表处于 1W 模式时它可以工作,但我们的想法是能够在 1D 或 4H 中使用它,但仍然可以看到图表并根据 1W 数据进行填充,因此分辨率参数。在这些时间范围内,填充消失但地块仍然存在。

//@version=4
study("SMA/EMA Ribbon", overlay=true, resolution="1W")

ribbon_period = input(20, "Period")

ema = ema(close, ribbon_period)
sma = sma(close, ribbon_period)

p1 = plot(ema, color= #53b987, title="EMA", transp = 50, linewidth = 1)
p2 = plot(sma, color= #eb4d5c, title="SMA", transp = 50, linewidth = 1)
fill(p1, p2, color = ema > sma ? #26d06a55 : #f3313d55)

请看下面代码:

我比较了上面和下面代码的输出,两者都给出了相同的输出值。

//@version=4
study("SMA/EMA Ribbon - Whosebug", overlay=true)


src = close, 

res = input(title="Use Different Timeframe? Uncheck Box Above", type=input.resolution, defval="W")

ribbon_period = input(20, "Period")

ema = security(syminfo.tickerid, res, ema(src, ribbon_period))
sma = security(syminfo.tickerid, res, sma(src, ribbon_period))

//EMA Plots
p1 = plot(ema, title="W EMA 20", linewidth=1, color=#53b987, transp = 50)
p2 = plot(sma, title="W SMA 20", linewidth=1, color=#eb4d5c, transp = 50)

fill(p1, p2, color = ema > sma ? #26d06a55 : #f3313d55)