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要求跨多行的表达式必须在每行末尾加\,否则编译器会认为该行语句已结束,触发语法错误。

修复方案

  1. 给三元运算符的每一行末尾添加\,标记表达式未结束
  2. 优化冗余的if-else判断:直接传入maTypeInput调用ma函数即可,无需重复做类型判断

修复后的完整代码

// 移动平均函数
ma(source, length, type) =>
    type == "SMA" ? ta.sma(source, length) :\
    type == "EMA" ? ta.ema(source, length) :\
    type == "SMMA (RMA)" ? ta.rma(source, length) :\
    type == "WMA" ? ta.wma(source, length) :\
    type == "VWMA" ? ta.vwma(source, length) : na

// 直接调用ma函数,替代冗余的if-else
maValue = ma(rsiValue, maLengthInput, maTypeInput)
rsiMA = maValue

补充说明

原代码中的if-else块完全重复了ma函数内部的判断逻辑,直接把maTypeInput作为参数传入ma函数,既能实现相同功能,还能大幅简化代码、避免冗余。

内容的提问来源于stack exchange,提问作者Brendon Travassos Rocha

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.14 08:27:17