嗨,我希望我的脚本回溯1个或2个栏,并且RSI是OS还是OB才能继续执行脚本,但是我找不到任何可以工作的
if (RSIOverBought = close[2])
...
(我知道这行不通,只是为了更容易理解)
答案 0 :(得分:1)
以下代码显示了有关如何引用先前的rsi值的示例。
//@version=4
study("RSI Barcolor",overlay=false)
length = input(15, "Length")
lookback = input(2, "Lookback")
ob = input(70, "Overbought")
os = input(30, "Oversold")
rsi = rsi(close, length)
var color col = na
if crossover(rsi[lookback], ob)
// do something here...
col := color.aqua
if crossunder(rsi[lookback], os)
// do something here...
col := color.yellow
if crossover(rsi[lookback], os) or crossunder(rsi[lookback], ob)
col := na
barcolor(col,offset=-lookback)
plot(rsi)
hline(ob)
hline(os)