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
相关产品推荐
相关产品推荐

