Pine脚本-无法在RSI指标自定义代码的BB指标中将源添加为RSI

时间:2020-09-04 19:57:18

标签: pine-script

我想在RSI上添加Bolinger Band

我已经完成了以下代码,但是我不断收到错误消息

据我所知,ibbsrc就是问题所在

// @version=4
study(title="RSI - BB", shorttitle="RSI-BB", format=format.price, precision=2)

//          RSI             //

len = input(14, minval=1, title="RSI Length")
rsisrc = input(close, "RSI Source", type = input.source)
up = rma(max(change(rsisrc), 0), len)
down = rma(-min(change(rsisrc), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
rsi1 = plot(rsi, "RSI", color=#ffa726)
band1 = hline(60, "RSI Upper Band", color=#C0C0C0)
band2 = hline(50, "RSI Middle Band", color=#C0C0C0)
band0 = hline(40, "RSI Lower Band", color=#C0C0C0)
fill(band1, band0, color=#ffa726, transp=92, title="RSI Background")

//          BB             //

length = 20
ibbsrc = rsi1
mult = 2
basis = sma(ibbsrc, length)
dev = mult * stdev(ibbsrc, length)
upper = basis + dev
lower = basis - dev
offset = input(0, "IBB Offset", type = input.integer, minval = -500, maxval = 500)
plot(basis, "IBB Basis", color=#872323, offset = offset)
p1 = plot(upper, "IBB Upper", color=color.teal, offset = offset)
p2 = plot(lower, "IBB Lower", color=color.teal, offset = offset)
fill(p1, p2, title = "IBB Background", color=#198787, transp=95)

当我这样做时出现以下错误

    Add to Chart operation failed, reason: 
    -line 69: Cannot call 'sma' with arguments (plot, const integer); available overloads: sma(series[float], series[integer]) => series[float];
    -line 70: Cannot call 'stdev' with arguments (plot, const integer); available overloads: stdev(series[float], integer) => series[float];
    -line 71: Undeclared identifier 'basis';
    -line 71: Undeclared identifier 'dev';
    -line 72: Undeclared identifier 'basis';
    -line 72: Undeclared identifier 'dev';
    -line 74: Undeclared identifier 'basis';
    -line 75: Undeclared identifier 'upper';
    -line 76: Undeclared identifier 'lower'

请帮助我解决问题!

0 个答案:

没有答案