我想为仅绘制长 atr 止损做一个新的输入。
atr SL 脚本:
// Stop Loss inputs atr
var atr_sl = "ATR Stoploss"
longLossPerc = input(title="Long Stop Loss (%)",type=input.float, group = atr_sl,minval=0.0, step=0.1, defval=1) * 0.01
atrLength = input(title="ATR Length", type=input.integer, group = atr_sl,defval=6, minval=1)
userStructure = input(title="Use Structure", type=input.bool, group = atr_sl, defval=true)
lookback = input(title="How far to look back for High/Low",type=input.integer,group = atr_sl,defval=7, minval=1)
atrStopMultiplier = input(title="ATR x ? ", type=input.float, group = atr_sl,defval=1.0, minval=0.1)
plotLong = input(title="Long ATR", type=input.bool, group= atr_sl, defval=false)
// calculate data atr
longStopPrice = strategy.position_avg_price * (1 - longLossPerc)
atr=atr(atrLength)
longStop = (userStructure ? lowest(low, lookback) : close) - atr * atrStopMultiplier
shortStop = (userStructure ? highest(high,lookback) : close) + atr * atrStopMultiplier
我应该使用if (plotLong == true)
参数来绘制这个脚本吗?如果是的话怎么办?
// plot
plot(longStop, color=color.green, style=plot.style_linebr, title="Long Trailing Stop-ATR")