简体   繁体   中英

I can not access this pine script alerts, what is the problem, line 11: Syntax error at input 'end of line without line continuation'

I can not access this pine script alerts, what is the problem/ line 11: Syntax error at input 'end of line without line continuation'

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © EzQuant

//@version=4

study(title="ATR Alerts", overlay = true)

nATRPeriod = input(5)

nATRMultip = input(3.5)

xATR = atr(nATRPeriod)

nLoss = nATRMultip * xATR

xATRTrailingStop = iff(close > nz(xATRTrailingStop[1], 0) and close[1] > nz(xATRTrailingStop[1], 0), max(nz(xATRTrailingStop[1]), close - nLoss),
                    iff(close < nz(xATRTrailingStop[1], 0) and close[1] < nz(xATRTrailingStop[1], 0), min(nz(xATRTrailingStop[1]), close + nLoss), 
                        iff(close > nz(xATRTrailingStop[1], 0), close - nLoss, close + nLoss)))
pos =   iff(close[1] < nz(xATRTrailingStop[1], 0) and close > nz(xATRTrailingStop[1], 0), 1,
        iff(close[1] > nz(xATRTrailingStop[1], 0) and close < nz(xATRTrailingStop[1], 0), -1, nz(pos[1], 0))) 

color = pos == -1 ? red: pos == 1 ? green : blue 

plot(xATRTrailingStop, color=color, title="ATR Trailing Stop")

barbuy = close > xATRTrailingStop 
barsell = close < xATRTrailingStop 


Buy=barbuy
Sell=barsell

barcolor(barbuy? green:red)

alertcondition(Buy, title='Ez ATR Bars, Long Alert', message='BUY EzCONTINUOUS {{ticker}} {{high}} {{low}} {{close}}')

alertcondition(Sell, title='Ez ATR Bars, Short Alert', message='SELL EzCONTINUOUS {{ticker}} {{high}} {{low}} {{close}}')

Your code was improperly formatted (see my comment) and some variables weren't declared.
This will compile.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © EzQuant
//@version=4
study(title="ATR Alerts", overlay = true)

var float xATRTrailingStop = na
var int   pos              = na

nATRPeriod       = input(5)
nATRMultip       = input(3.5)

xATR             = atr(nATRPeriod)
nLoss            = nATRMultip * xATR
xATRTrailingStop := iff(close > nz(xATRTrailingStop[1], 0) and close[1] > nz(xATRTrailingStop[1], 0), max(nz(xATRTrailingStop[1]), close - nLoss), iff(close < nz(xATRTrailingStop[1], 0) and close[1] < nz(xATRTrailingStop[1], 0), min(nz(xATRTrailingStop[1]), close + nLoss), iff(close > nz(xATRTrailingStop[1], 0), close - nLoss, close + nLoss))) 
pos              := iff(close[1] < nz(xATRTrailingStop[1], 0) and close > nz(xATRTrailingStop[1], 0), 1, iff(close[1] > nz(xATRTrailingStop[1], 0) and close < nz(xATRTrailingStop[1], 0), -1, nz(pos[1], 0)))
myColor          = pos == -1 ? color.red : pos == 1 ? color.green : color.blue
barbuy           = close > xATRTrailingStop 
barsell          = close < xATRTrailingStop
Buy              = barbuy 
Sell             = barsell

plot(xATRTrailingStop, color=myColor, title="ATR Trailing Stop")
barcolor(barbuy? color.green : color.red)

alertcondition(Buy,  title='Ez ATR Bars, Long Alert',  message='BUY EzCONTINUOUS {{ticker}} {{high}} {{low}} {{close}}')
alertcondition(Sell, title='Ez ATR Bars, Short Alert', message='SELL EzCONTINUOUS {{ticker}} {{high}} {{low}} {{close}}')

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