Pine script Tradeview:pinescript错误:应为';没有行延续的行结束';
在tradeview中编译以下代码时,我遇到以下错误。基本上,我尝试使用EMA/SMA字符串来计算MACD 第20行:不匹配的输入“ema”应为“行尾无行延续” 有人能告诉我我错过了什么吗?有没有更好的编码方法 另外,我们可以在if-else语句中有多行,还是应该只有一行Pine script Tradeview:pinescript错误:应为';没有行延续的行结束';,pine-script,Pine Script,在tradeview中编译以下代码时,我遇到以下错误。基本上,我尝试使用EMA/SMA字符串来计算MACD 第20行:不匹配的输入“ema”应为“行尾无行延续” 有人能告诉我我错过了什么吗?有没有更好的编码方法 另外,我们可以在if-else语句中有多行,还是应该只有一行 study("MACD BB - PRD") //MACD Inputs //--------------------------------------------------------------- fastLengt
study("MACD BB - PRD")
//MACD Inputs
//---------------------------------------------------------------
fastLength = input(defval=12, title="MACD.FastPeriod", minval=1, maxval=50, step=1)
slowLength = input(defval=26, title="MACD.SlowPeriod", minval=1, maxval=200, step=1)
signalLength= input(defval=9, title="MACD.SignalLength", minval=1, maxval=100, step=1)
macdMode = input(defval="EMA", title="MACD.AverageMode", options=["EMA","SMA"])
//Bollinger Bands Inputs
//---------------------------------------------------------------
bbPeriod = input(defval=9, title="MACD.SignalLength", minval=1, maxval=100, step=1)
bbMultipler = input(defval=1, title="MACD.SignalLength", minval=1, maxval=10, step=0.1)
bbMode = input(defval="EMA", title="BollingerBands.AverageMode", options=["EMA","SMA"])
//---------------------------------------------------------------
// MACD calculation
macd = if (macdMode == "EMA")
ema(close, fastLength) - ema(close, slowLength) // line20
else
sma(close, fastLength) - sma(close, slowLength)
你的问题是缩进。您必须将if语句主体内的代码移位4个空格或1个制表符
// MACD calculation
macd = if (macdMode == "EMA")
ema(close, fastLength) - ema(close, slowLength) // line20
else
sma(close, fastLength) - sma(close, slowLength)
我们可以在if-else语句中有多行吗?还是应该是
只有一行吗
study("MACD BB - PRD")
//MACD Inputs
//---------------------------------------------------------------
fastLength = input(defval=12, title="MACD.FastPeriod", minval=1, maxval=50, step=1)
slowLength = input(defval=26, title="MACD.SlowPeriod", minval=1, maxval=200, step=1)
signalLength= input(defval=9, title="MACD.SignalLength", minval=1, maxval=100, step=1)
macdMode = input(defval="EMA", title="MACD.AverageMode", options=["EMA","SMA"])
//Bollinger Bands Inputs
//---------------------------------------------------------------
bbPeriod = input(defval=9, title="MACD.SignalLength", minval=1, maxval=100, step=1)
bbMultipler = input(defval=1, title="MACD.SignalLength", minval=1, maxval=10, step=0.1)
bbMode = input(defval="EMA", title="BollingerBands.AverageMode", options=["EMA","SMA"])
//---------------------------------------------------------------
// MACD calculation
macd = if (macdMode == "EMA")
ema(close, fastLength) - ema(close, slowLength) // line20
else
sma(close, fastLength) - sma(close, slowLength)
对
TradingView中有一个可能会对您有所帮助。为什么这个标签上有“apl”?您是想使用“api”吗?如果我可以在pine脚本上使用它,将把它翻译成api,甚至可能大写字母会澄清区别:标签“apl”指的是一种编程语言(您可能不打算谈论它)。“api”是一个应用程序编程接口。