Pine Script报错修复求助:Mismatched input 'end of line without line continuation'
修复Pine Script的“end of line without line continuation”语法错误
这个错误源于多行函数调用的语法不符合Pine Script的解析规则,具体修复分两种场景:
场景1:使用Pine Script v4
v4版本要求多行函数调用的每个参数行末尾必须加逗号(包括最后一个参数),修改后的代码如下:
myLabel := label.new( x=bar_index, y=high, text="NPL: " + tostring(npl), yloc=yloc.abovebar, color=color.green, textcolor=color.white, style=label.style_label_left, )
场景2:使用Pine Script v5
v5版本支持最后一个参数不加逗号,但如果是重复赋值myLabel,需要提前声明变量,修改后的代码如下:
// 提前声明标签变量 var label myLabel = na // 赋值标签 myLabel := label.new( x=bar_index, y=high, text="NPL: " + tostring(npl), yloc=yloc.abovebar, color=color.green, textcolor=color.white, style=label.style_label_left )
也可以直接将函数调用写在一行,规避多行解析问题:
myLabel := label.new(x=bar_index, y=high, text="NPL: " + tostring(npl), yloc=yloc.abovebar, color=color.green, textcolor=color.white, style=label.style_label_left)
内容的提问来源于stack exchange,提问作者Matias Ignacio
相关产品推荐
相关产品推荐

