我无法访问此松树脚本警报,这是什么问题/ 第11行:输入“无行延续的行尾”的语法错误
// 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}}')
答案 0 :(得分:1)
您的代码格式不正确(请参阅我的评论),并且未声明某些变量。
这将编译。
// 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}}')