[英]Cannot use a mutable variable as an argument of the security function
下面的脚本无法编译。
它抛出错误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。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.