Dual-Confirmation Range Filter Strategy with ATR Dynamic Position Sizing and Trailing Stop System
FMZQuant

FMZQuant @fmzquant

Joined:
Apr 25, 2024

Dual-Confirmation Range Filter Strategy with ATR Dynamic Position Sizing and Trailing Stop System

Publish Date: Jun 11
2 1

Image description

Image description

Overview
This strategy is a low-drawdown quantitative trading system that combines Range Filter and Average True Range (ATR). It identifies trend direction through the range filter while using ATR to dynamically adjust position size and set trailing stops, effectively controlling risk. The strategy requires price to break above or below the range filter for two consecutive periods to confirm a trend, and this dual-confirmation mechanism effectively reduces false breakouts. The system defaults to risking 1% of capital per trade, which is conservative and robust. This strategy is particularly suitable for markets with high volatility but clear trends.

Strategy Principles
The core principles of this strategy combine range filter trend identification with an ATR risk management system:

Range Filter Calculation:

  • First calculates a Simple Moving Average (SMA) of price as the center line
  • Then calculates the moving average of the absolute deviation between price and the center line as the volatility range
  • Upper band = Center line + Volatility range
  • Lower band = Center line - Volatility range

Trend Confirmation Conditions:

  • Uptrend: Price closes above the upper band for two consecutive periods
  • Downtrend: Price closes below the lower band for two consecutive periods
  • This dual-confirmation mechanism reduces false signals

ATR Dynamic Position Sizing:

  • Uses ATR to measure current market volatility
  • Position size formula: (Account equity * Risk percentage) / (ATR * Point value)
  • Higher market volatility leads to smaller positions; lower volatility leads to larger positions

ATR Trailing Stops:

  • Long stop loss set at: Current price - (ATR * Multiplier)
  • Short stop loss set at: Current price + (ATR * Multiplier)
  • As price moves favorably, the stop loss line moves accordingly, locking in profits

Strategy Advantages
Strong Adaptability:

  • Range filter automatically adapts to volatility characteristics of different market cycles
  • ATR position adjustment mechanism enables the strategy to automatically adapt to different volatility environments

Excellent Risk Control:

  • Fixed risk percentage per trade (default 1%)
  • Dynamically adjusts position size based on market volatility
  • Trailing stop mechanism effectively locks in profits and limits losses

High Signal Quality:

  • Dual-confirmation mechanism (consecutive two-period breakout) reduces false signals
  • Range filter effectively filters out market noise and identifies true trends

Low Drawdown Characteristics:

  • Trailing stop mechanism limits the maximum loss of a single trade
  • Conservative risk parameter settings (1% risk) reduce overall drawdown
  • Dynamic positioning automatically reduces during high volatility periods, lowering risk

Transparent and Customizable:

  • Clear strategy parameters and logic
  • Parameters can be adjusted according to different markets and personal risk preferences

Strategy Risks
Poor Performance in Ranging Markets:

  • In trendless, consolidating markets, frequent false breakout signals may occur
  • Solution: Additional trend filters can be added or the number of confirmation periods increased

Rapid Reversal Risk:

  • During sudden reversals of strong trends, trailing stops may not exit positions quickly enough
  • Solution: Incorporate volatility indicators or tighten trailing stop distances

Parameter Sensitivity:

  • The choice of range filter period and ATR multiplier significantly impacts strategy performance
  • Solution: Conduct thorough historical backtesting to find robust parameter combinations

Consecutive Loss Risk:

  • Even with good risk control per trade, consecutive losing trades can still lead to significant drawdowns
  • Solution: Set limits on maximum consecutive losses or add market environment filters

Slippage and Commission Impact:

  • In live trading, slippage and commissions can significantly affect strategy performance
  • Solution: Include reasonable commission and slippage estimates in backtesting, maintain sufficient profit margin

Strategy Optimization Directions
Add Market Environment Filters:

  • Introduce volatility indicators (such as Bollinger Bandwidth) to identify market states
  • Pause trading or adjust parameters in low-volatility or ranging markets
  • This can reduce false signals in ranging markets and improve overall win rate

Optimize Range Filter Period:

  • Consider using adaptive periods rather than fixed periods
  • Automatically adjust range filter period based on market volatility
  • This will allow the strategy to better adapt to different market phases

Introduce Multi-Timeframe Confirmation:

  • Add trend confirmation conditions on higher timeframes
  • Trade only in the direction of the major trend, avoiding counter-trend trades
  • This will significantly improve signal quality and win rate

Dynamically Adjust ATR Multiplier:

  • Dynamically adjust the ATR multiplier for trailing stops based on market volatility characteristics
  • Use smaller multipliers in low-volatility markets and larger multipliers in high-volatility markets
  • This will improve the effectiveness and flexibility of stop losses

Add Time-Based Exit Mechanisms:

  • Set maximum holding time limits
  • Force position closure if price doesn't develop as expected within a certain time
  • This can prevent capital from being tied up in ineffective trades for long periods

Summary
The Dual-Confirmation Range Filter Strategy with ATR Dynamic Position Sizing and Trailing Stop System is a quantitative trading strategy focused on risk control. It identifies trend direction through the range filter, requires consecutive two-period breakouts to confirm signals, and uses ATR to dynamically adjust position size and set trailing stops, effectively controlling risk per trade within a preset percentage. The main advantages of this strategy are its strong adaptability and excellent risk control capabilities, making it particularly suitable for markets with high volatility but clear trends. The main risks come from false breakouts in ranging markets and sensitivity to parameter selection. Future optimization directions include adding market environment filters, introducing multi-timeframe analysis, and dynamically adjusting parameters. For traders pursuing a robust, low-drawdown trading style, this is a strategy framework worth considering, which can be further customized and optimized according to individual risk preferences and trading instrument characteristics.

Strategy source code

/*backtest
start: 2025-02-01 00:00:00
end: 2025-05-25 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"SOL_USDT"}]
*/

//@version=5
strategy("Range Filter + ATR Strategy (Low Drawdown)", overlay=true, 
     pyramiding=0, default_qty_type=strategy.percent_of_equity, 
     default_qty_value=100, commission_type=strategy.commission.percent, 
     commission_value=0.1, initial_capital=10000)

// Input parameters
rangePeriod = input.int(14, title="Range Filter Period")
atrPeriod = input.int(14, title="ATR Period")
riskPercent = input.float(1.0, title="Risk % per Trade", minval=0.1, maxval=5)
useATRSizing = input(true, title="Use ATR Position Sizing")
trailATR = input(1.5, title="Trailing Stop ATR Multiple")

// Calculate Range Filter
src = close
smooth = ta.sma(src, rangePeriod)
filter = ta.sma(math.abs(src - smooth), rangePeriod)
upper = smooth + filter
lower = smooth - filter

// Calculate ATR
atr = ta.atr(atrPeriod)

// Trend direction
upTrend = src > upper and src[1] > upper[1]
downTrend = src < lower and src[1] < lower[1]

// Position sizing based on ATR
atrPositionSize = (strategy.equity * riskPercent/100) / (atr * syminfo.pointvalue)

// Strategy logic
if (upTrend)
    strategy.entry("Long", strategy.long, qty=useATRSizing ? atrPositionSize : na)

if (downTrend)
    strategy.entry("Short", strategy.short, qty=useATRSizing ? atrPositionSize : na)

// Corrected trailing stop using trail_offset instead of trail_points
if (strategy.position_size > 0)
    strategy.exit("Long Exit", "Long", trail_price=na, trail_offset=trailATR * atr)

if (strategy.position_size < 0)
    strategy.exit("Short Exit", "Short", trail_price=na, trail_offset=trailATR * atr)

// Plotting
plot(upper, color=color.green, title="Upper Range")
plot(lower, color=color.red, title="Lower Range")
plot(smooth, color=color.blue, title="Smooth Line")
Enter fullscreen mode Exit fullscreen mode

Strategy parameters

Image description

The original address: Dual-Confirmation Range Filter Strategy with ATR Dynamic Position Sizing and Trailing Stop System

Comments 1 total

  • Raxrb Kuech
    Raxrb KuechJun 12, 2025

    Finally, a strategy smarter than my 'panic-buy-ATH' technique! 😂 The ATR dynamic sizing is chef's kiss - though my emotions still prefer 'YOLO sizing'. Jokes aside, systematic stops beat my 'hold till broke' strategy any day!

Add comment