Pinesccript:无法从以下位置翻译脚本:



我正试图在TradingView Pinescript中创建一个多重移动平均脚本。不幸的是,它不断抛出错误:

脚本无法从以下位置翻译:["EMA"、"SMA"、"WMA"、"HMA"one_answers"LIN"]

我似乎不知道我的语法是否不正确,或者是否缺少其他东西。

任何人能提供的帮助都将不胜感激。

study("SPY Indicators", shorttitle="SPY Ind", overlay=true)
//@version=1
// Version 1.0
// Author: Likwid

// Definitions: Price and Timeframes
src = input(close, title = "Source")
resolution = timeframe.period
price = security(syminfo.tickerid, resolution, src)
// Defintions: Moving Average periods and types
ma1Period = input(defval=8, title="Period", inline="1", group="Moving Averages: Zone 1")
ma1Type = input(defval="EMA", title="Type", type=input.string, options=["EMA","SMA","WMA","HMA","LIN"], tooltip="MA Smoothing", inline="1", group="Moving Averages: Zone 1")
ma2Period = input(defval=21, title="Period", inline="2", group="Moving Averages: Zone 1")
ma2Type = input(defval="EMA", title="Type", type=input.string, options=["EMA","SMA","WMA","HMA","LIN"], tooltip="MA Smoothing", inline="2", group="Moving Averages: Zone 1")
ma3Period = input(defval=34, title="Period", inline="3", group="Moving Averages: Zone 2")
ma3Type = input(defval="EMA", title="Type", type=input.string, options=["EMA","SMA","WMA","HMA","LIN"], tooltip="MA Smoothing", inline="3", group="Moving Averages: Zone 2")
ma4Period = input(defval=50, title="Period", inline="4", group="Moving Averages: Zone 2")
ma4Type = input(defval="EMA", title="Type", type=input.string, options=["EMA","SMA","WMA","HMA","LIN"], tooltip="MA Smoothing", inline="4", group="Moving Averages: Zone 2")
ma5Period = input(defval=200, title="Period", inline="5", group="Moving Averages: Other")
ma5Type = input(defval="EMA", title="Type", type=input.string, options=["EMA","SMA","WMA","HMA","LIN"], tooltip="MA Smoothing", inline="5", group="Moving Averages: Other")
vwSwitch = input(title="VWAP", type=input.bool, defval=true, inline="6", group="Moving Averages: Other")
vwPeriod = input(defval=9, title="Period", inline="6", group="Moving Averages: Other")
// Moving Average Calculation
ma1 = ma1Type == "EMA" ? ema(price, ma1Period) :
ma1Type == "SMA" ? sma(price, ma1Period) :
ma1Type == "WMA" ? wma(price, ma1Period) :
ma1Type == "HMA" ? hma(price, ma1Period) :
ma1Type == "LIN" ? linreg(price, ma1Period, 0) : na
ma2 = ma2Type == "EMA" ? ema(price, ma2Period) :
ma2Type == "SMA" ? sma(price, ma2Period) :
ma2Type == "WMA" ? wma(price, ma2Period) :
ma2Type == "HMA" ? hma(price, ma2Period) :
ma2Type == "LIN" ? linreg(price, ma2Period, 0) : na
ma3 = ma3Type == "EMA" ? ema(price, ma3Period) :
ma3Type == "SMA" ? sma(price, ma3Period) :
ma3Type == "WMA" ? wma(price, ma3Period) :
ma3Type == "HMA" ? hma(price, ma3Period) :
ma3Type == "LIN" ? linreg(price, ma3Period, 0) : na
ma4 = ma4Type == "EMA" ? ema(price, ma4Period) :
ma4Type == "SMA" ? sma(price, ma4Period) :
ma4Type == "WMA" ? wma(price, ma4Period) :
ma4Type == "HMA" ? hma(price, ma4Period) :
ma4Type == "LIN" ? linreg(price, ma4Period, 0) : na

ma5 = ma5Type == "EMA" ? ema(price, ma5Period) :
ma5Type == "SMA" ? sma(price, ma5Period) :
ma5Type == "WMA" ? wma(price, ma5Period) :
ma5Type == "LIN" ? linreg(price, ma5Period, 0) : na
// Definitions: Trends
TrendUp1() => ma1 > ma2
TrendDown1() => ma1 < ma2
TrendUp2() => ma3 > ma4
TrendDown2() => ma3 < ma4
trendColor1 = TrendUp1() ? color.green : TrendDown1() ? color.red : color.blue
trendColor2 = TrendUp2() ? color.blue : TrendDown2() ? color.red : color.blue

// Moving Average plots
fill(ma1, ma2, color=trendColor1, transp=70)
fill(ma3, ma4, color=trendColor2, transp=70)
plot(ma5, color=color.red, linewidth=2, style=plot.style_line)
plot(vwSwitch ? vwap(hlc3) : na, color=color.white, linewidth=1, style=plot.style_line)

脚本第一行缺少//@version=4
我还对// Moving Average plots部分进行了一些调整,因为您不能在2个系列之间使用fill()
只能在plot((和hline((对象之间使用fill()

//@version=4
study("SPY Indicators", shorttitle="SPY Ind", overlay=true)
// Version 1.0
// Author: Likwid
// Definitions: Price and Timeframes
src = input(close, title = "Source")
resolution = timeframe.period
price = security(syminfo.tickerid, resolution, src)
// Defintions: Moving Average periods and types
ma1Period = input(defval=8, title="Period", inline="1", group="Moving Averages: Zone 1")
ma1Type = input(defval="EMA", title="Type", type=input.string, options=["EMA","SMA","WMA","HMA","LIN"], tooltip="MA Smoothing", inline="1", group="Moving Averages: Zone 1")
ma2Period = input(defval=21, title="Period", inline="2", group="Moving Averages: Zone 1")
ma2Type = input(defval="EMA", title="Type", type=input.string, options=["EMA","SMA","WMA","HMA","LIN"], tooltip="MA Smoothing", inline="2", group="Moving Averages: Zone 1")
ma3Period = input(defval=34, title="Period", inline="3", group="Moving Averages: Zone 2")
ma3Type = input(defval="EMA", title="Type", type=input.string, options=["EMA","SMA","WMA","HMA","LIN"], tooltip="MA Smoothing", inline="3", group="Moving Averages: Zone 2")
ma4Period = input(defval=50, title="Period", inline="4", group="Moving Averages: Zone 2")
ma4Type = input(defval="EMA", title="Type", type=input.string, options=["EMA","SMA","WMA","HMA","LIN"], tooltip="MA Smoothing", inline="4", group="Moving Averages: Zone 2")
ma5Period = input(defval=200, title="Period", inline="5", group="Moving Averages: Other")
ma5Type = input(defval="EMA", title="Type", type=input.string, options=["EMA","SMA","WMA","HMA","LIN"], tooltip="MA Smoothing", inline="5", group="Moving Averages: Other")
vwSwitch = input(title="VWAP", type=input.bool, defval=true, inline="6", group="Moving Averages: Other")
vwPeriod = input(defval=9, title="Period", inline="6", group="Moving Averages: Other")
// Moving Average Calculation
ma1 = ma1Type == "EMA" ? ema(price, ma1Period) :
ma1Type == "SMA" ? sma(price, ma1Period) :
ma1Type == "WMA" ? wma(price, ma1Period) :
ma1Type == "HMA" ? hma(price, ma1Period) :
ma1Type == "LIN" ? linreg(price, ma1Period, 0) : na
ma2 = ma2Type == "EMA" ? ema(price, ma2Period) :
ma2Type == "SMA" ? sma(price, ma2Period) :
ma2Type == "WMA" ? wma(price, ma2Period) :
ma2Type == "HMA" ? hma(price, ma2Period) :
ma2Type == "LIN" ? linreg(price, ma2Period, 0) : na
ma3 = ma3Type == "EMA" ? ema(price, ma3Period) :
ma3Type == "SMA" ? sma(price, ma3Period) :
ma3Type == "WMA" ? wma(price, ma3Period) :
ma3Type == "HMA" ? hma(price, ma3Period) :
ma3Type == "LIN" ? linreg(price, ma3Period, 0) : na
ma4 = ma4Type == "EMA" ? ema(price, ma4Period) :
ma4Type == "SMA" ? sma(price, ma4Period) :
ma4Type == "WMA" ? wma(price, ma4Period) :
ma4Type == "HMA" ? hma(price, ma4Period) :
ma4Type == "LIN" ? linreg(price, ma4Period, 0) : na

ma5 = ma5Type == "EMA" ? ema(price, ma5Period) :
ma5Type == "SMA" ? sma(price, ma5Period) :
ma5Type == "WMA" ? wma(price, ma5Period) :
ma5Type == "LIN" ? linreg(price, ma5Period, 0) : na
// Definitions: Trends
TrendUp1() => ma1 > ma2
TrendDown1() => ma1 < ma2
TrendUp2() => ma3 > ma4
TrendDown2() => ma3 < ma4
trendColor1 = TrendUp1() ? color.green : TrendDown1() ? color.red : color.blue
trendColor2 = TrendUp2() ? color.blue : TrendDown2() ? color.red : color.blue

// Moving Average plots
p_ma1 = plot(ma1)
p_ma2 = plot(ma2)
p_ma3 = plot(ma3)
p_ma4 = plot(ma4)
fill(p_ma1, p_ma2, color=trendColor1, transp=70)
fill(p_ma3, p_ma4, color=trendColor2, transp=70)
plot(ma5, color=color.red, linewidth=2, style=plot.style_line)
plot(vwSwitch ? vwap(hlc3) : na, color=color.white, linewidth=1, style=plot.style_line)

最新更新