该策略是一个基于布林带突破的高级趋势跟踪系统,结合了RSI和ADX等多重技术指标作为过滤条件,并采用基于ATR的动态止损和追踪止盈机制。策略采用了严格的风险管理方法,通过多重指标的配合使用来提高交易的准确性和稳定性。
策略的核心逻辑基于以下几个关键要素: 1. 使用20周期的布林带作为主要趋势判断指标,带宽为2倍标准差 2. 通过RSI(14)的中性区间(40-60)过滤假突破 3. 利用手动计算的ADX(14)>25确认趋势强度 4. 入场信号: - 多头:价格突破上轨且满足RSI和ADX过滤条件 - 空头:价格突破下轨且满足RSI和ADX过滤条件 5. 风险管理: - 基于1.5倍ATR设置初始止损 - 使用1倍ATR的追踪止损 - 止损跟随距离为0.5倍ATR
这是一个结构完善的趋势跟踪策略,通过多重技术指标的协同作用提高了交易的稳定性。策略的风险管理体系完善,能够有效控制下行风险。虽然存在一些优化空间,但整体设计理念符合现代量化交易的要求。策略适合在波动性较大的市场中应用,对于追求稳健收益的交易者来说是一个不错的选择。
/*backtest
start: 2025-02-01 00:00:00
end: 2025-02-19 00:00:00
period: 1h
basePeriod: 1m
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/
//@version=5
strategy("Optimized Bollinger Bands Breakout Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=1)
// 🎯 Bollinger Bands Settings
length = input(20, title="Bollinger Length")
mult = input(2.0, title="Bollinger Multiplier")
basis = ta.sma(close, length)
dev = mult * ta.stdev(close, length)
upperBand = basis + dev
lowerBand = basis - dev
// 📌 ADX Calculation (Manually Calculated)
adxLength = input(14, title="ADX Length")
dmiLength = input(14, title="DMI Length")
upMove = high - ta.highest(high[1], 1)
downMove = ta.lowest(low[1], 1) - low
plusDM = upMove > downMove and upMove > 0 ? upMove : 0
minusDM = downMove > upMove and downMove > 0 ? downMove : 0
plusDI = ta.sma(plusDM, dmiLength) / ta.atr(dmiLength) * 100
minusDI = ta.sma(minusDM, dmiLength) / ta.atr(dmiLength) * 100
dx = math.abs(plusDI - minusDI) / (plusDI + minusDI) * 100
adx = ta.sma(dx, adxLength)
// 📌 Additional Filters
rsi = ta.rsi(close, 14)
// ✅ Entry Conditions
longCondition = ta.crossover(close, upperBand) and rsi > 40 and rsi < 60 and adx > 25
shortCondition = ta.crossunder(close, lowerBand) and rsi > 40 and rsi < 60 and adx > 25
// 📌 ATR-based Stop Loss
stopLossMultiplier = input(1.5, title="Stop Loss (ATR Multiplier)")
atrValue = ta.atr(14)
longSL = close - (atrValue * stopLossMultiplier)
shortSL = close + (atrValue * stopLossMultiplier)
// ✅ Trailing Stop
trailMultiplier = input(1, title="Trailing Stop Multiplier")
longTrailStop = close - (atrValue * trailMultiplier)
shortTrailStop = close + (atrValue * trailMultiplier)
// 🚀 Executing Trades
if (longCondition)
strategy.entry("Long", strategy.long)
strategy.exit("Exit Long", from_entry="Long", stop=longSL, trail_price=longTrailStop, trail_offset=atrValue * 0.5)
if (shortCondition)
strategy.entry("Short", strategy.short)
strategy.exit("Exit Short", from_entry="Short", stop=shortSL, trail_price=shortTrailStop, trail_offset=atrValue * 0.5)
// 📊 Plot Bollinger Bands
plot(upperBand, title="Upper Band", color=color.blue)
plot(lowerBand, title="Lower Band", color=color.red)
plot(basis, title="Middle Band", color=color.gray)