想用pinescript写一个场景

问题描述 投票:0回答:1

我是 pinescript 新手,我想检查第二根蜡烛的收盘价是否低于第一根蜡烛的高点,我该如何检查。有人可以告诉我我该怎么做吗

我尝试了以下但不起作用

//@version=5
indicator("Gap Up and Close Below Daily High Checker", overlay=true)

// Input for percentage threshold for gap-up
gapThresholdPercent = input.float(1, title="Gap Threshold (%)", minval=0, maxval=10, step=0.1)

// Calculate the percentage change from the previous close to the current open
gapUpPercent = ((open - close[1]) / close[1]) * 100

// Check if the current open is a gap-up based on the threshold
isGapUp = gapUpPercent > gapThresholdPercent



higherClose = close >= open[1]
closeLower  = close[1] < close[2]


// Plotting shapes on the chart for visualization
bgcolor(isGapUp ? color.new(color.green, 90) : na)


// Displaying information on the chart
plotshape(series=isGapUp, title="Gap Up", color=color.green, style=shape.triangleup, size=size.small, location=location.belowbar)
plotshape(series=higherClose, title="High", color=color.green, style=shape.triangleup, size=size.small, location=location.belowbar)
plotshape(series=closeLower, title="Low", color=color.red, style=shape.triangledown, size=size.small, location=location.belowbar)
pine-script tradingview-api trading
1个回答
0
投票
//@version=5
indicator("Gap Up and Close Below Daily High Checker", overlay=true)

// Input for percentage threshold for gap-up
gapThresholdPercent = input.float(1, title="Gap Threshold (%)", minval=0maxval=10, step=0.1)
var bool isGapUp=na
var bool higherClose=na
var bool closeLower=na

if(barstate.isconfirmed)
    gapUpPercent = ((open - close[1]) / close[1]) * 100
    isGapUp:= gapUpPercent > gapThresholdPercent
    higherClose:= close > high[1]
    closeLower := close < low[1]

// Plotting shapes on the chart for visualization
bgcolor(isGapUp ? color.new(color.green, 90) : na)

// Displaying information on the chart
plotshape(series=isGapUp, title="Gap Up", color=color.green, style=shape.triangleup, size=size.small, location=location.belowbar)
plotshape(higherClose, title="High", color=color.green, style=shape.triangleup, size=size.small, location=location.belowbar)
plotshape(closeLower, title="Low", color=color.red, style=shape.triangledown, size=size.small, location=location.belowbar)
© www.soinside.com 2019 - 2024. All rights reserved.