该策略是一个基于分形理论和自适应网格的短线交易系统,结合了波动率阈值来优化交易时机。系统通过动态调整网格水平,在高波动期间捕捉市场微观结构变化,同时在低波动期间避免过度交易。策略集成了多重技术指标,包括平均真实波幅(ATR)、简单移动平均线(SMA)和分形突破点,构建了一个全面的交易决策框架。
策略的核心是通过分形识别和波动率聚类来建立动态交易网格。具体实现包括以下几个关键步骤: 1. 使用枢轴高点(Pivot High)和枢轴低点(Pivot Low)识别局部极值点作为分形突破信号 2. 利用ATR指标度量市场波动性,并设定最小波动阈值作为交易触发条件 3. 基于ATR值和用户定义的乘数动态调整网格水平 4. 使用SMA确定趋势方向,为交易决策提供方向性偏差 5. 在网格水平设置限价订单,并根据ATR值调整止损和获利点位
这是一个结合了分形理论、网格交易和波动率过滤的综合性策略系统。通过多重技术指标的配合使用,实现了对市场微观结构的有效捕捉。策略的优势在于其自适应性和风险控制能力,但同时也需要注意参数优化和市场环境适应性的问题。通过持续优化和完善,该策略有望在不同市场环境下保持稳定的表现。
/*backtest
start: 2024-02-17 00:00:00
end: 2025-02-15 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=6
strategy("Adaptive Fractal Grid Scalping Strategy", overlay=true)
// Inputs
atrLength = input.int(14, title="ATR Length")
smaLength = input.int(50, title="SMA Length")
gridMultiplierHigh = input.float(2.0, title="Grid Multiplier High")
gridMultiplierLow = input.float(0.5, title="Grid Multiplier Low")
trailStopMultiplier = input.float(0.5, title="Trailing Stop Multiplier")
volatilityThreshold = input.float(1.0, title="Volatility Threshold (ATR)")
// Calculate Fractals
fractalHigh = ta.pivothigh(high, 2, 2)
fractalLow = ta.pivotlow(low, 2, 2)
// Calculate ATR and SMA
atrValue = ta.atr(atrLength)
smaValue = ta.sma(close, smaLength)
// Determine Trend Direction
isBullish = close > smaValue
isBearish = close < smaValue
// Calculate Grid Levels
gridLevelHigh = fractalHigh + atrValue * gridMultiplierHigh
gridLevelLow = fractalLow - atrValue * gridMultiplierLow
// Plot Fractals and Grid Levels
plotshape(not na(fractalHigh), style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)
plotshape(not na(fractalLow), style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)
plot(gridLevelHigh, color=color.red, linewidth=1, title="Grid Level High")
plot(gridLevelLow, color=color.green, linewidth=1, title="Grid Level Low")
// Trade Execution Logic with Volatility Threshold
if (atrValue > volatilityThreshold)
if (isBullish and not na(fractalLow))
strategy.entry("Buy", strategy.long, limit=gridLevelLow)
if (isBearish and not na(fractalHigh))
strategy.entry("Sell", strategy.short, limit=gridLevelHigh)
// Profit-Taking and Stop-Loss
strategy.exit("Take Profit/Stop Loss", "Buy", limit=gridLevelHigh, stop=fractalLow - atrValue * trailStopMultiplier)
strategy.exit("Take Profit/Stop Loss", "Sell", limit=gridLevelLow, stop=fractalHigh + atrValue * trailStopMultiplier)