pine在循环的第一行上引发语法错误
我有一种松树策略:
//@version=5
strategy("Elie's strategy", overlay=true, margin_long=100, margin_short=100)
var float[] overSRLs = na
var IDCounter = 0
int[] removeFromOver = na
for int i = 0 to (array.size(overSRLs) - 1) // line 8
if low < array.get(overSRLs, i)
orderID = str.tostring(IDCounter)
exitID = str.tostring(IDCounter + 1)
IDCounter += 2
strategy.order(orderID, strategy.long, 1)
strategy.exit(exitID, from_entry=orderID, stop = (array.get(overSRLs, i) * (1 - ATR5[1])), limit = (array.get(overSRLs, i) * (1 + ATR5[1]))
array.push(removeFromOver, i)
我知道这不是一项策略,但是我切掉了无关紧要的部分,以制作一个较小的可生殖典范。当仅保存上面的代码时,它会引发以下错误:
line 8: Syntax error at input 'int'.
现在,即使第8行是的的初始化,我认为问题在
,编译器/解释器的错误处理不好。我在这里缺少什么吗?一切对我来说都很好
I have a pine strategy:
//@version=5
strategy("Elie's strategy", overlay=true, margin_long=100, margin_short=100)
var float[] overSRLs = na
var IDCounter = 0
int[] removeFromOver = na
for int i = 0 to (array.size(overSRLs) - 1) // line 8
if low < array.get(overSRLs, i)
orderID = str.tostring(IDCounter)
exitID = str.tostring(IDCounter + 1)
IDCounter += 2
strategy.order(orderID, strategy.long, 1)
strategy.exit(exitID, from_entry=orderID, stop = (array.get(overSRLs, i) * (1 - ATR5[1])), limit = (array.get(overSRLs, i) * (1 + ATR5[1]))
array.push(removeFromOver, i)
I know it's not much of a strategy, but I cut out the irrelevant parts to make a smaller reproductible example. When just the code above is saved, it throws the following error:
line 8: Syntax error at input 'int'.
Now, even though line 8 is the init of the for
, I think the problem is in the code block in the for
, and the compiler/interpreter just has bad error handling. Is there something I'm missing here? Everything looks fine to me
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,问题是在
strateger.exit
中 - 最终需要一个额外的闭合括号。编译器并不总是为循环中的错误提供正确的行。评论循环并将所有内容移动到左侧,您会发现新错误是第14行:输入处的语法错误'('。
,这表明 它找不到它的一对)。打开括号(因为 可读性。
Yes, the issue is in the
strategy.exit
-- you need one extra closing bracket in the end there. Compiler does not always provide correct lines for errors in loops. Comment out the loop and move everything one tab to the left and you'll see that the new error isline 14: Syntax error at input '('.
, which indicates that there is an issue with the opening bracket (because it can't find its pair).P.S. The script will not compile after that because of the undeclared
ATR5
variable, but I assume it's due to the fact that you trimmed the example code for readability.