You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.26 11:52:48