下面的脚本无法编译。
它抛出错误Cannot use a mutable variable as an argument of the security function
我不明白为什么。
我在安全函数中使用的参数不是可变变量。
当我注释掉该行时h := h * 3
,脚本编译正常。
有人知道这是怎么回事吗?
这可能是 Pine 脚本错误吗?
//@version=4
study("My Script")
[h, l, c] = security(syminfo.ticker, "D", [high,low,close], lookahead = barmerge.lookahead_on) // actual daily high,low,close.
h := h * 3 // Commenting this line results removes the error: "Cannot use a mutable variable as an argument of the security function."
plot(h)
由于某种原因,当用户定义的函数返回解构赋值时,解构赋值的处理方式与当用户定义函数返回解构赋值时的处理方式不同security()
做。封装你的security()
调用函数将起作用:
//@version=4
study("")
f_sec() => security(syminfo.tickerid, "D", [high,low,close], lookahead = barmerge.lookahead_on)
[h, l, c] = f_sec()
h := h * 3
plot(h)
请注意,在使用前瞻时,您使用的是历史柱上的未来数据,而不是像您在其中所做的那样将系列偏移 1。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)