简体   繁体   中英

“Syntax error at input 'end of line without line continuation'.”

I'm trying to execute this code on TradingView:

//@version=4
study(title="MACD", shorttitle="MACD", resolution="")

// Getting inputs
fast_length = input(title="Fast Length", type=input.integer, defval=12)
slow_length = input(title="Slow Length", type=input.integer, defval=26)
source = input(title="Source", type=input.source, defval=close)
signal_length = input(title="Signal Smoothing", type=input.integer, minval = 1, maxval = 50, defval = 9)

switch1=input(true, title="Enable Bar Color?")
switch2=input(true, title="Enable Background Color?")

sma_source = input(title="Simple MA(Oscillator)", type=input.bool, defval=false)
sma_signal = input(title="Simple MA(Signal Line)", type=input.bool, defval=false)

fast_ma = sma_source ? sma(source, fast_length) : ema(source, fast_length)
slow_ma = sma_source ? sma(source, slow_length) : ema(source, slow_length)
macd = fast_ma - slow_ma
signal = sma_signal ? sma(macd, signal_length) : ema(macd, signal_length)
hist = macd - signal


// Plot colors
col_grow_above = #26A69A
col_grow_below = #FFCDD2
col_fall_above = #B2DFDB
col_fall_below = #EF5350
col_macd = #0094ff
col_signal = #ff6a00

// Calculating

plot(hist, title="Histogram", style=plot.style_columns, color=(hist>=0 ? (hist[1] < hist ? col_grow_above : col_fall_above) : (hist[1] < hist ? col_grow_below : col_fall_below) ), transp=0 )
plot(macd, title="MACD", color=col_macd, transp=0)
plot(signal, title="Signal", color=col_signal, transp=0)

// Histogram Color
GetHistogramColor = iff(hist > 0, 1,
                    iff(hist < 0, -1, nz(GetHistogramColor[1], 0))) 
     
ColorHistogram = GetHistogramColor == -1 ? red: GetHistogramColor == 1 ? green : blue 
plot(hist, color=ColorHistogram, style=histogram,linewidth=4)

"Syntax error at input 'end of line without line continuation'."

I tried so many combinations of spaces and tabs before the "iffs" but in vain.

Please help.

Thank you

Without errors

//@version=4
study(title="MACD", shorttitle="MACD", resolution="")

// Getting inputs
fast_length = input(title="Fast Length", type=input.integer, defval=12)
slow_length = input(title="Slow Length", type=input.integer, defval=26)
source = input(title="Source", type=input.source, defval=close)
signal_length = input(title="Signal Smoothing", type=input.integer, minval = 1, maxval = 50, defval = 9)

switch1=input(true, title="Enable Bar Color?")
switch2=input(true, title="Enable Background Color?")

sma_source = input(title="Simple MA(Oscillator)", type=input.bool, defval=false)
sma_signal = input(title="Simple MA(Signal Line)", type=input.bool, defval=false)

fast_ma = sma_source ? sma(source, fast_length) : ema(source, fast_length)
slow_ma = sma_source ? sma(source, slow_length) : ema(source, slow_length)
macd = fast_ma - slow_ma
signal = sma_signal ? sma(macd, signal_length) : ema(macd, signal_length)
hist = macd - signal


// Plot colors
col_grow_above = #26A69A
col_grow_below = #FFCDD2
col_fall_above = #B2DFDB
col_fall_below = #EF5350
col_macd = #0094ff
col_signal = #ff6a00

// Calculating

plot(hist, title="Histogram", style=plot.style_columns, color=(hist>=0 ? (hist[1] < hist ? col_grow_above : col_fall_above) : (hist[1] < hist ? col_grow_below : col_fall_below) ), transp=0 )
plot(macd, title="MACD", color=col_macd, transp=0)
plot(signal, title="Signal", color=col_signal, transp=0)

// Histogram Color
GetHistogramColor = 0
GetHistogramColor := iff(hist > 0, 1, 
                     iff(hist < 0, -1, nz(GetHistogramColor[1]))) 
     
ColorHistogram = GetHistogramColor == -1 ? color.red: GetHistogramColor == 1 ? color.green : color.blue 
plot(hist, color=ColorHistogram, style=plot.style_histogram,linewidth=4) 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM