Pine script 不能将可变变量用作安全函数的参数

Pine script 不能将可变变量用作安全函数的参数,pine-script,Pine Script,下面的脚本无法编译。 它抛出错误无法将可变变量用作安全函数的参数 我不明白为什么。 我在安全函数中使用的参数不是可变变量。 当我注释掉行h:=h*3时,脚本编译正常。 有人知道这里发生了什么吗? 这可能是一个Pine脚本错误吗 //@version=4 study("My Script") [h, l, c] = security(syminfo.ticker, "D", [high,low,close], lookahead = barmerge.lo

下面的脚本无法编译。
它抛出错误
无法将可变变量用作安全函数的参数

我不明白为什么。
我在安全函数中使用的参数不是可变变量。
当我注释掉行
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。

我知道我使用的是未来数据,因为我需要知道第一个条形图上的高/低。不知道你用1来抵消这个系列是什么意思。就我所知,我没有这么做。