'长度的pinescript errorInvalid值' ta.highest()和ta.highestbars()中的参数(0.0)
参考以下代码 绘制temp1给出了错误,而绘制temp2 plottest OK ???任何建议
//@version=5
indicator("HighBar Test", overlay=false)
var temp1 = 0
var temp2 = 0
var length_1 = 0
var length_2 = 0
length_1 := bar_index - bar_index[50]
length_2 := 50
// eample 1
temp1 := ta.highestbars(length_1)
//plot(temp1)
// example 2
temp2 := ta.highestbars(length_2)
plot(temp2)
plot(length_2)
referring to the code below
plotting temp1 gives the error whereas plotting temp2 plottest OK
??? any suggestions
//@version=5
indicator("HighBar Test", overlay=false)
var temp1 = 0
var temp2 = 0
var length_1 = 0
var length_2 = 0
length_1 := bar_index - bar_index[50]
length_2 := 50
// eample 1
temp1 := ta.highestbars(length_1)
//plot(temp1)
// example 2
temp2 := ta.highestbars(length_2)
plot(temp2)
plot(length_2)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
运行时错误在ta.highestbars()函数的长度=参数值的问题上指示该问题,该值应该是超过零的整数值。
在图表上的第一个49个bar中,
bar_index [50]
呼叫将返回 na ,因为参考尚不存在,因此bar_index -na == na
,请注意,数学运算符不支持 na 值的计算。您可以使用内置的nz()
函数进行替换:The runtime error indicates on the issue with the ta.highestbars() function's length= argument value, which should be an integer value above zero.
During the first 49 bars on the chart, the
bar_index[50]
call would return na, as the reference is not existing yet, hence thebar_index - na == na
, note that math operators do not support calculations with na values. You can protect it using the built-innz()
function with replacement: