【问题标题】:How to mark candle stick which is not surpassed MA50如何标记未超过 MA50 的烛台
【发布时间】:2020-11-28 17:12:42
【问题描述】:

我正在尝试为只有阴影交叉 MA50 的烛台设置数据标签。你能告诉我这个的代码吗?非常感谢!

enter image description here

【问题讨论】:

    标签: pine-script algorithmic-trading


    【解决方案1】:

    下面的代码将绘制您询问的内容,但您可能需要考虑使用bgcolor(),而不是使用标签。图表上的标签数量是有限的,而bgcolor() 没有这个限制。

    //@version=4
    study("My Script", overlay=true)
    
    src     = input(close, "Source", type=input.source)
    len     = input(50, "Moving average length", type=input.integer, minval=1)
    
    ma      = sma(src, len)
    show    = barstate.isconfirmed and high > ma and max(open,close) < ma
    
    if show
        label.new(bar_index, high, "V", yloc=yloc.abovebar)
    
    bgcolor(show ? color.yellow : na)
    plot(ma, "SMA")
    

    此屏幕截图表明,如果您在图表上返回足够远,您可以看到标签停止生成:

    【讨论】:

      猜你喜欢
      • 2018-10-10
      • 1970-01-01
      • 2013-08-06
      • 2014-04-10
      • 1970-01-01
      • 2022-06-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多