我对编码很陌生,当RSI被超买/超卖时,我发现了如何创建一个信号。我希望当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)发布于 2021-06-22 14:45:59
您可以使用barstate.isconfirmed等到条形图以及内置于函数中的crossover()和crossunder()关闭时再使用。
crossunderOB = barstate.isconfirmed and crossunder(rsiValue, rsiOverbought)
crossoverOS = barstate.isconfirmed and crossover(rsiValue, rsiOversold)发布于 2021-06-23 05:59:44
“我希望在蜡烛3的结束时产生信号,它在蜡烛3的下方穿过。”
只需使用类似的东西
cbd=crossunder(rsiValue,75)
cbu=crossover(rsiValue,25)
https://stackoverflow.com/questions/68081438
复制相似问题