如何定义点火棒的低点?
How to define the low of the igniting bar?
我正在编写一个代码来寻找上升趋势中的红色条,我已经定义了我正在寻找的第一个绿色条和第一个红色条,但我想将此条件添加到redCandle,我希望前一个柱的高点减去收盘价小于收盘价减去第一个绿色柱的低点,如下所示:
(high[1]-close) < (close-"the low of the firstGreen")
.
如您所见,我不知道如何定义 firstGreen 的低点。我应该放什么?
谢谢
这是代码
//@version=4
study(title="Red Bar", overlay=true)
// Calculate moving averages
fastMA = sma(close, 20)
slowMA = sma(close, 200)
//RBI
FirstGreen= barstate.isconfirmed and (open < close) and (close[1] < open[1])
redCandle = barstate.isconfirmed and (close < open) and (fastMA < open) and (slowMA < close)
//Plots
plotshape(series=redCandle, style=shape.circle, color=#ff00ff, location=location.abovebar)
// ALERTAS
alertcondition(redCandle, title='RBI', message="Red Alert")
您可以使用 valuewhen()
。
Returns the value of the source
series on the bar where the
condition
was true on the nth most recent occurrence.
firstGreenLow = valuewhen(FirstGreen, low, 0)
我正在编写一个代码来寻找上升趋势中的红色条,我已经定义了我正在寻找的第一个绿色条和第一个红色条,但我想将此条件添加到redCandle,我希望前一个柱的高点减去收盘价小于收盘价减去第一个绿色柱的低点,如下所示:
(high[1]-close) < (close-"the low of the firstGreen")
.
如您所见,我不知道如何定义 firstGreen 的低点。我应该放什么? 谢谢 这是代码
//@version=4
study(title="Red Bar", overlay=true)
// Calculate moving averages
fastMA = sma(close, 20)
slowMA = sma(close, 200)
//RBI
FirstGreen= barstate.isconfirmed and (open < close) and (close[1] < open[1])
redCandle = barstate.isconfirmed and (close < open) and (fastMA < open) and (slowMA < close)
//Plots
plotshape(series=redCandle, style=shape.circle, color=#ff00ff, location=location.abovebar)
// ALERTAS
alertcondition(redCandle, title='RBI', message="Red Alert")
您可以使用 valuewhen()
。
Returns the value of the
source
series on the bar where thecondition
was true on the nth most recent occurrence.
firstGreenLow = valuewhen(FirstGreen, low, 0)