【问题标题】:How to get value at a point of line extended - TradingView Pine script如何在延长线的点处获得价值 - TradingView Pine 脚本
【发布时间】:2021-06-08 01:21:48
【问题描述】:

我用下面的代码画了一条线:

//@version=4

simplesma = sma(close, 14)

var line3 = line.new(bar_index[0], high[0], bar_index, low, extend = extend.right)
line.set_xy1(line3, bar_index[5], simplesma[5])
line.set_xy2(line3, bar_index[3], simplesma[3])

这条线是用历史上的 2 个点绘制的。

然后我用这段代码画一个情节

price_point = line.get_price(line3,bar_index)
plot(price_point, title='Price', color=#ffcc00, transp=30)

我试图在标签上显示值,但以下代码不起作用:

var label3 = label.new(bar_index, high, text = "Value: "+ tostring(price_point, "#.########"), style = label.style_label_lower_left, color=#ffcc00, textcolor=#ff0000)
label.set_xy(label3,bar_index, price_point)

你能帮我把它显示在标签上吗?

【问题讨论】:

    标签: charts pine-script trading


    【解决方案1】:

    变量 price_point 是当前柱 (bar_index) 处的值。你不需要使用函数tostring()

    【讨论】:

      【解决方案2】:

      哦,我找到了。

      var label3 = label.new(bar_index, high, text = "", style = label.style_label_lower_left, color=#ffcc00, textcolor=#ff0000)
      label.set_xy(label3,bar_index, price_point)
      label.set_text(label3, "Value: "+ tostring(price_point, "#.########"))
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-09-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-08-04
        • 2020-02-10
        相关资源
        最近更新 更多