
This strategy is a scalping system based on fractal theory and adaptive grid, combined with volatility threshold for trade timing optimization. The system dynamically adjusts grid levels to capture market microstructure changes during high volatility periods while avoiding overtrading during low volatility periods. The strategy integrates multiple technical indicators, including Average True Range (ATR), Simple Moving Average (SMA), and fractal breakout points, building a comprehensive trading decision framework.
The core of the strategy lies in establishing dynamic trading grids through fractal identification and volatility clustering. The specific implementation includes the following key steps: 1. Using Pivot High and Pivot Low to identify local extremes as fractal breakout signals 2. Utilizing ATR indicator to measure market volatility and setting minimum volatility threshold as trading trigger 3. Dynamically adjusting grid levels based on ATR values and user-defined multipliers 4. Using SMA to determine trend direction, providing directional bias for trading decisions 5. Setting limit orders at grid levels and adjusting stop-loss and take-profit points based on ATR values
This is a comprehensive strategy system combining fractal theory, grid trading, and volatility filtering. Through the coordinated use of multiple technical indicators, it achieves effective capture of market microstructure. The strategy’s strengths lie in its adaptability and risk control capabilities, while attention needs to be paid to parameter optimization and market environment adaptability. Through continuous optimization and improvement, the strategy has the potential to maintain stable performance across different market environments.
/*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)