该策略是一个结合了ZigZag指标和Aroon指标的自适应交易系统。ZigZag指标用于过滤市场噪音并识别重要的价格波动,而Aroon指标则用于确认趋势的强度和潜在的反转点。策略通过这两个指标的协同配合,在保持对趋势敏感性的同时,也能够及时捕捉市场的转折点。
策略的核心逻辑基于以下几个关键要素: 1. ZigZag指标通过设定深度参数(zigzagDepth)来过滤短期波动,只保留具有统计意义的价格波动。 2. Aroon指标通过计算最高价和最低价出现的时间间隔(aroonLength),生成Aroon Up和Aroon Down两条线。 3. 入场信号由两个条件共同触发: - Aroon Up突破Aroon Down时,同时ZigZag显示上升趋势,则开立多仓 - Aroon Down突破Aroon Up时,同时ZigZag显示下降趋势,则开立空仓 4. 出场信号则由Aroon指标的交叉来触发: - 多仓在Aroon Down上穿Aroon Up时平仓 - 空仓在Aroon Up上穿Aroon Down时平仓
该策略通过ZigZag和Aroon指标的结合,构建了一个较为完整的趋势跟踪系统。策略的优势在于其自适应性和双重确认机制,但同时也需要注意参数选择和市场环境对策略表现的影响。通过持续优化和改进,该策略有望在实际交易中取得稳定表现。
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-10 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Zig Zag + Aroon Strategy", overlay=true)
// Zig Zag parameters
zigzagDepth = input(5, title="Zig Zag Depth")
// Aroon parameters
aroonLength = input(14, title="Aroon Length")
// Zig Zag logic
var float lastZigZag = na
var float lastZigZagHigh = na
var float lastZigZagLow = na
var int direction = 0 // 1 for up, -1 for down
// Calculate Zig Zag
if (not na(high) and high >= ta.highest(high, zigzagDepth) and direction != 1)
lastZigZag := high
lastZigZagHigh := high
direction := 1
if (not na(low) and low <= ta.lowest(low, zigzagDepth) and direction != -1)
lastZigZag := low
lastZigZagLow := low
direction := -1
// Aroon calculation
highestHigh = ta.highest(high, aroonLength)
lowestLow = ta.lowest(low, aroonLength)
aroonUp = (aroonLength - (bar_index - ta.highestbars(high, aroonLength))) / aroonLength * 100
aroonDown = (aroonLength - (bar_index - ta.lowestbars(low, aroonLength))) / aroonLength * 100
// Long entry condition
longCondition = (ta.crossover(aroonUp, aroonDown)) and (lastZigZag == lastZigZagHigh)
if (longCondition)
strategy.entry("Long", strategy.long)
// Short entry condition
shortCondition = (ta.crossover(aroonDown, aroonUp)) and (lastZigZag == lastZigZagLow)
if (shortCondition)
strategy.entry("Short", strategy.short)
// Exit conditions
if (ta.crossover(aroonDown, aroonUp) and strategy.position_size > 0)
strategy.close("Long")
if (ta.crossover(aroonUp, aroonDown) and strategy.position_size < 0)
strategy.close("Short")
// Plot Zig Zag
plot(lastZigZag, color=color.blue, title="Zig Zag", linewidth=2, style=plot.style_stepline)
// Plot Aroon
hline(70, "Aroon Up Overbought", color=color.red)
hline(30, "Aroon Down Oversold", color=color.green)
plot(aroonUp, color=color.green, title="Aroon Up")
plot(aroonDown, color=color.red, title="Aroon Down")