在 MTF 的 2 条移动平均线之间填充

Fill between 2 moving average on MTF

我的图表上有 2 个 HMA。我将解释我的设置。 我的图表在 H1 上打开。其中我将一个 HMA 设置为 H1。然后我将第二个 HMA 设置为 H4 TF。我已经能够毫无问题地对它们进行编码。我想要做的是填充 2 HMA 之间的 space。如果 H1 超过 H4,则填充蓝色。如果 H4 越过 H1 填充黄色。到目前为止,我无法获得可靠的填充。它显示为条形。

//@version=4

study(title="MTF HMA", shorttitle="HMA", overlay=true)
length = input(70, minval=1, title="Length")
src = input(close, title="Source")
out = wma(2*wma(src, length/2)-wma(src, length), floor(sqrt(length)))
res = input(title="Resolution", type=input.resolution, defval="60")
s1 = security(syminfo.tickerid, res, out, gaps=true)
hma1 = plot(s1, color=#2196F3)


out1 = wma(2*wma(src, length/2)-wma(src, length), floor(sqrt(length)))
res1 = input(title="Resolution", type=input.resolution, defval="240")
s2 = security(syminfo.tickerid, res1, out1, gaps=true)
hma2 = plot(s2, color=#ffeb3b)

fill(hma1, hma2, color=s1<s2 ? #2196F3 : #ffeb3b)

Results so far

通过使用fixnan()

https://www.tradingview.com/pine-script-reference/v4/#fun_fixnan

s2 = fixnan(security(syminfo.tickerid, res1, out1, gaps=true))