【问题标题】:Filling 2 MA with resolution用分辨率填充 2 MA
【发布时间】:2021-05-25 05:03:22
【问题描述】:

您好,我正在尝试绘制分辨率为 W 的 EMA 和 SMA 并填充它们之间的背景。 这是我的代码:

study("Support Band", overlay=true, resolution="W")

src = input(close)

ema = input(21, minval=1, title='EMA')
sma = input(20, minval=1, title='SMA')

pema = ema(src, ema)
psma = sma(src, sma)

//fil
emaplot = plot(pema, color=#2ecc71, linewidth=1, title='EMA')
smaplot = plot(psma, color=#f00b0b, linewidth=1, title='SMA')

fill(emaplot, smaplot, color=pema>psma? color.rgb(0, 255, 0, 50):color.rgb(255, 0, 0, 50), editable=true, fillgaps=true)

由于某种原因,在查看每日时背景未填充,但在查看每周时显示。我尝试过填充间隙但没有用。任何帮助表示赞赏。

谢谢

【问题讨论】:

    标签: pine-script


    【解决方案1】:

    早上,

    在多个时间范围内进行测试并发挥作用。

    study(title="StackOverFlow123", shorttitle="StackOverFlow123", overlay=true)
    
    len21 = input(21, minval=1, title="Length")
    len20 = input(20, minval=1, title="Length")
    
    res = input(title="Resolution", type=input.string, defval="W")
    
    pema = security(syminfo.tickerid, res, ema(close, len21))
    psma = security(syminfo.tickerid, res, sma(close, len20))
    
    emaplot = plot(pema, color=#2ecc71, linewidth=1, title='EMA')
    smaplot = plot(psma, color=#f00b0b, linewidth=1, title='SMA')
    
    
    fill(emaplot, smaplot, color=pema>psma? color.rgb(0, 255, 0, 50):color.rgb(255, 0, 0, 50), editable=true, fillgaps=true)
    

    【讨论】:

    • 非常感谢,添加了“barmerge.gaps_on”以使其平滑。
    猜你喜欢
    • 2013-03-11
    • 2015-02-18
    • 2015-04-29
    • 1970-01-01
    • 1970-01-01
    • 2017-01-14
    • 2020-12-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多