[英]Undeclared identifier in Pine loop
I have this code:我有这个代码:
// Average penetration
high_pen = for i = 0 to penetration_len
penetration = high[i] - shortEma[i]
sum = high_pen + penetration
high_pen = penetration > 0 ? sum : 0
high_pen
average_high_pen = high_pen / penetration_len
As you can see, I just want to get all penetration in a bullish trend.如您所见,我只想在看涨趋势中获得所有渗透。 The compiler says that high_pen var is not declared in " sum = high_pen + penetration " sentence.
编译器说high_pen var 未在“ sum = high_pen + 渗透”语句中声明。 It is a very simple loop which it only has to sum the penetration.
这是一个非常简单的循环,它只需要对渗透进行求和。
How can I do that correctly?我怎样才能正确地做到这一点? How should I declare the high_pen var and use it after the loop?
我应该如何声明high_pen 变量并在循环后使用它?
Can't validate because your snippet is partial, but this should work:无法验证,因为您的代码片段是部分的,但这应该有效:
// Average penetration
high_pen = 0.
for i = 0 to penetration_len
penetration = high[i] - shortEma[i]
sum = high_pen + penetration
high_pen := penetration > 0 ? sum : 0
average_high_pen = high_pen / penetration_len
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.