由于 "side effects",指示器警报不起作用

Indicator alert not working because of "side effects"

这是我的第一个 post!我正在尝试编写一个 Pine 脚本,实际上只是在价格越过略微修改的 BB 指标的下限时添加警报。当我尝试将它添加到图表时,出现以下错误:

"Add to Chart operation failed, reason: line 18: The 'timeframe' argument is incompatible with functions that have side effects."

这是我的代码,有人可以帮助我理解我做错了什么吗?非常感谢!

//@version=5
indicator(shorttitle="BB_WMA", title="Bollinger Bands WMA", overlay=true, timeframe="", timeframe_gaps=true)
length = input.int(20, minval=1)
src = input(close, title="Source")
mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev")
basis = ta.wma(src, length)
dev = mult * ta.stdev(src, length)
upper = basis + dev
lower = basis - dev
offset = input.int(0, "Offset", minval = -500, maxval = 500)
plot(basis, "Basis", color=#FF6D00, offset = offset)
p1 = plot(upper, "Upper", color=#2962FF, offset = offset)
p2 = plot(lower, "Lower", color=#2962FF, offset = offset)
fill(p1, p2, title = "Background", color=color.rgb(33, 150, 243, 95))
//Buy Alert
BAlert = ta.crossover(volume,lower)
if BAlert
    alert("Buy", alert.freq_once_per_bar)

我已经尝试删除时间范围参数,将“音量”更改为“关闭”,但没有解决问题。

从您的声明中删除 (timeframe="", timeframe_gaps=true)

如果需要,请在脚本的其他位置设置时间范围参数