Pinescript 在 RSI 低于某个值时发出警报
Pinescript to fire an alert when the RSI crosses back below a value
我是编码新手,我已经找到了如何在 RSI 变为 overbought/oversold 时创建信号。当 RSI 越过该水平时,我想让该警报真正触发。
例如:超买水平设置为 80,蜡烛 1 为 75,蜡烛 2 达到 85,蜡烛 3 然后回落至 75。我希望在蜡烛 3 收盘时生成信号回到下方(希望这是有道理的)。
//@version=4
study(title="RSI cross back", shorttitle="RSI Signal", overlay=true)
// Get user input
rsiSource = input(title="RSI Source", type=input.source, defval=close)
rsiLength = input(title="RSI Length", type=input.integer, defval=10)
rsiOverbought = input(title="RSI Overbought Level", type=input.integer, defval=80)
rsiOversold = input(title="RSI Oversold Level", type=input.integer, defval=20)
// Get RSI value
rsiValue = rsi(rsiSource, rsiLength)
RsiOB = rsiValue >= rsiOverbought
RsiOS = rsiValue <= rsiOversold
// Plot signals to chart
plotshape(RsiOB, title="Overbought", location=location.abovebar, color=color.red, transp=0, style=shape.triangledown)
plotshape(RsiOS, title="Oversold", location=location.belowbar, color=color.green, transp=0, style=shape.triangleup)
您可以使用 barstate.isconfirmed
等待柱线收盘以及 crossover()
和 crossunder()
内置函数
crossunderOB = barstate.isconfirmed and crossunder(rsiValue, rsiOverbought)
crossoverOS = barstate.isconfirmed and crossover(rsiValue, rsiOversold)
“我希望信号在蜡烛 3 的收盘时产生,它向下交叉”
只需使用类似
的东西
cbd=crossunder(rsiValue,75)
cbu=交叉(rsiValue,25)
我是编码新手,我已经找到了如何在 RSI 变为 overbought/oversold 时创建信号。当 RSI 越过该水平时,我想让该警报真正触发。
例如:超买水平设置为 80,蜡烛 1 为 75,蜡烛 2 达到 85,蜡烛 3 然后回落至 75。我希望在蜡烛 3 收盘时生成信号回到下方(希望这是有道理的)。
//@version=4
study(title="RSI cross back", shorttitle="RSI Signal", overlay=true)
// Get user input
rsiSource = input(title="RSI Source", type=input.source, defval=close)
rsiLength = input(title="RSI Length", type=input.integer, defval=10)
rsiOverbought = input(title="RSI Overbought Level", type=input.integer, defval=80)
rsiOversold = input(title="RSI Oversold Level", type=input.integer, defval=20)
// Get RSI value
rsiValue = rsi(rsiSource, rsiLength)
RsiOB = rsiValue >= rsiOverbought
RsiOS = rsiValue <= rsiOversold
// Plot signals to chart
plotshape(RsiOB, title="Overbought", location=location.abovebar, color=color.red, transp=0, style=shape.triangledown)
plotshape(RsiOS, title="Oversold", location=location.belowbar, color=color.green, transp=0, style=shape.triangleup)
您可以使用 barstate.isconfirmed
等待柱线收盘以及 crossover()
和 crossunder()
内置函数
crossunderOB = barstate.isconfirmed and crossunder(rsiValue, rsiOverbought)
crossoverOS = barstate.isconfirmed and crossover(rsiValue, rsiOversold)
“我希望信号在蜡烛 3 的收盘时产生,它向下交叉”
只需使用类似
的东西cbd=crossunder(rsiValue,75)
cbu=交叉(rsiValue,25)