【问题标题】:How to plot % change across X candles in Tradingview Pine Script?如何在 Tradingview Pine Script 中绘制 X 根蜡烛的百分比变化?
【发布时间】:2021-11-02 07:07:15
【问题描述】:

所以我只是想在收盘价在 5 根蜡烛上变化 20% 的位置下方绘制绿色三角形。 Pine 脚本给出了 plotshape 的语法错误。你不能在 plotshape 中设置条件吗?

study(title="20% change in 5 candles", overlay=true)

var Diff = 0
var PercentChange = 0

// Identify % change 5 candles away
Diff = close - close[5]
PercentChange = Diff / close[5]

// Plot signals to chart
   plotshape(series=PercentChange > 0.2, title="Here", location=location.belowbar, color=color.green, style=shape.triangleup, text="here")

// Send out an alert if this candle meets our conditions
alertcondition(PercentChange > 0.2, title="20% change in 5 candles!", message="20% change in 5 candles")

【问题讨论】:

    标签: plot syntax-error pine-script


    【解决方案1】:
    1. var Diff = 0var PercentChange 初始化为 int,但后来您将其分配给 float 的关闭值。 采用 var float = 0var Diff = 0.0
    2. 稍后您需要使用 := 运算符而不是 = 重新分配 var 值: Diff := close - close[5]
    3. plotshape 函数前错误的额外缩进。
    //@version=4
    study(title="20% change in 5 candles", overlay=true)
    
    var float Diff = 0
    var PercentChange = 0.0
    
    // Identify % change 5 candles away
    Diff := close - close[5]
    PercentChange := Diff / close[5]
    
    // Plot signals to chart
    plotshape(series=PercentChange > 0.2, title="Here", location=location.belowbar, color=color.green, style=shape.triangleup, text="here")
    
    // Send out an alert if this candle meets our conditions
    alertcondition(PercentChange > 0.2, title="20% change in 5 candles!", message="20% change in 5 candles")
    

    【讨论】:

      猜你喜欢
      • 2022-10-01
      • 2020-09-19
      • 1970-01-01
      • 2021-08-17
      • 2023-01-25
      • 1970-01-01
      • 2022-01-27
      • 2023-02-17
      • 2021-01-24
      相关资源
      最近更新 更多