我在叠加的指示器中很好地使用了标签,但是现在我试图在窗格中使用它(在我定制的基本v5 MACD代码中)。
label.new(hist[0] < hist[1] and hist[2] < hist[1] and ShowLabels ? bar_index : na, high, color=#FF0000, text="S", textcolor=color.white, tooltip = "MACD Sell", style=label.style_label_down)
它带着以下错误消息返回:
The 'timeframe' argument is incompatible with functions that have side effects
我怀疑bar_index
和/或high
是有问题的,但没有找到如何使label.new()
函数符合窗格。
发布于 2022-09-24 10:15:44
引起问题的是label.new()
函数。
timeframe
的indicator()
参数是为了提供一种快速和简单的方法来完成MTF。当您收到此错误时,这意味着为其他时间框架计算脚本失败。
这将发生当你有图纸,因为他们不是那么容易计算在其他线框。
即使是以下情况也会触发此错误:
label.new(na, na, na)
line.new(na, na, na, na)
box.new(na, na, na, na)
解决办法是,将timeframe
参数从indicator()
中移除,并使用security()
函数从其他时间框架中计算所需的值。然后在绘图函数调用中使用这些值。
https://stackoverflow.com/questions/73836223
复制相似问题