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

Pine Script 报错:end of line without line continuation 求助

解决Pine Script中"end of line without line continuation"语法错误

问题分析

你这段代码的语法错误出在三元运算符的换行处理上。Pine Script对多行三元表达式有严格要求:如果三元表达式拆分到多行书写,必须在每行末尾的冒号后添加行续符\,否则解释器会认为表达式已结束,触发语法报错。

修正后的代码

ma(source, length, type) =>
    type == "SMA" ? ta.sma(source, length) : \
    type == "EMA" ? ta.ema(source, length) : na

修改说明

  • 在第一个三元分支的冒号后添加\,明确告知解释器该行表达式未结束,下一行是内容延续
  • 若追求简洁,也可将整个三元表达式写在同一行,同样能正常运行:
    ma(source, length, type) =>
        type == "SMA" ? ta.sma(source, length) : type == "EMA" ? ta.ema(source, length) : na
    

内容的提问来源于stack exchange,提问作者Hamguy

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.13 01:49:52