我如何才能长期做这种策略,关闭多头头寸而不是做空呢?
非常感谢!
//Noro
//2019
//@version=3
strategy(title = "Noro's TrendTrader Strategy v1.0", shorttitle = "TT str", overlay = true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, pyramiding = 0)
//Settings
len = input(21, minval=1)
mult = input(3, minval=1)
//Line
atr = wma(atr(1), len)
highestC = highest(len)
lowestC = lowest(len)
hiLimit = highestC[1] - (atr[1] * mult)
loLimit = lowestC[1] + (atr[1] * mult)
ret = 0.0
ret := close > hiLimit and close > loLimit ? hiLimit : close < loLimit and close < hiLimit ? loLimit : nz(ret[1])
plot(ret, color= blue , title = "Trend Trader")
//Trading
if low > ret and close < open
strategy.entry("L", strategy.long)
if high < ret and close > open
strategy.entry("S", strategy.short)