
The Twin Range Filter Dynamic Trend Following Strategy is an intelligent trading system based on price volatility that constructs a dual-confirmation trend identification mechanism by combining fast and slow independent range filter sets. The strategy’s core lies in using Exponential Moving Averages (EMA) to calculate smooth average true ranges, then building upper and lower bands based on this dynamic volatility indicator to form an adaptive price channel. When price breaks through this dynamic channel, the strategy generates corresponding trading signals based on breakout direction and trend persistence.
This strategy is particularly suitable for Renko charts because Renko charts filter out time factors and focus on price movements, which highly aligns with the core concept of range filter strategies. Through the dual range filter mechanism, the strategy effectively reduces market noise interference in trading decisions while maintaining sensitivity to genuine trend changes. This design enables the strategy to avoid frequent false signals in oscillating markets while promptly capturing effective price breakouts in trending markets.
The strategy’s intelligence is reflected in its adaptability, dynamically adjusting range width to accommodate different market volatility environments, ensuring it won’t be overly sensitive in high-volatility markets or too sluggish in low-volatility markets.
The core principle of the Twin Range Filter Dynamic Trend Following Strategy is built upon the statistical characteristics of price volatility. The strategy first calculates smooth average fluctuation ranges through the smoothrng function, which uses exponential moving averages to perform double smoothing on absolute price changes. The first smoothing calculates the EMA of absolute price changes, while the second smoothing uses a period that is twice the original period minus one. This dual smoothing mechanism effectively eliminates short-term noise while maintaining responsiveness to medium and long-term volatility changes.
The strategy designs two parameter systems: fast parameters (per1=27, mult1=1.5) for capturing short-term price changes, and slow parameters (per2=55, mult2=1.0) for identifying long-term trends. The average of both ranges serves as the final dynamic range width, balancing the strategy’s sensitivity and stability.
The range filter (rngfilt function) is the strategy’s core component, dynamically adjusting the filter line position by comparing current price with the previous period’s filter value. When price rises, the filter line is set to the greater of current price minus range width and the previous filter value; when price falls, the filter line is set to the smaller of current price plus range width and the previous filter value. This mechanism ensures the filter line can follow price trend changes while providing sufficient buffer zones to filter short-term fluctuations.
The strategy records consecutive rising and falling periods through upward and downward variables, helping judge trend strength and persistence. Signal generation requires meeting both price position relative to the filter line and trend direction persistence conditions, significantly improving signal reliability through this dual confirmation mechanism.
The Twin Range Filter Dynamic Trend Following Strategy possesses multiple significant advantages. First is its exceptional adaptive capability - the strategy automatically adjusts range width based on market volatility changes, meaning it expands tolerance ranges to reduce misjudgments in high-volatility markets and tightens ranges to improve sensitivity in low-volatility markets. This adaptive mechanism enables consistent performance across various market environments.
Second is the advantage of the dual confirmation mechanism. Through combining fast and slow filter systems plus dual verification of price position and trend persistence, the strategy significantly reduces false signal probability. This design is particularly suitable for handling noise trading and short-term volatility interference common in financial markets.
Another important advantage is excellent trend-following capability. Through continuous counting mechanisms, the strategy can identify and persistently track strong trends, avoiding premature exits from profitable positions. When trends reverse, the strategy can also promptly identify and adjust position directions.
From a risk management perspective, the strategy incorporates dynamic stop-loss mechanisms. The upper and lower band design naturally provides risk control functionality - trading signals trigger when price breaks through bands, while stop-losses or position closures may trigger when price returns within bands. This design ensures every trade has clear risk boundaries.
The strategy also demonstrates good parameter stability. Despite multiple adjustable parameters, the strategy shows relatively low parameter sensitivity, meaning consistent performance across different market environments while reducing over-optimization risks.
Despite numerous advantages, the Twin Range Filter Dynamic Trend Following Strategy still has several risk points requiring attention. The primary risk is performance issues in oscillating markets. When markets are in sideways consolidation, price may frequently cross the filter line, causing excessive trading signals. While dual confirmation mechanisms can reduce this occurrence, the strategy may still face consecutive small loss risks in strongly oscillating markets.
Solutions include adding market environment identification modules, such as introducing volatility indicators or trend strength indicators to determine whether current markets suit the strategy. When strong oscillation environments are detected, trading can be temporarily suspended or parameter settings adjusted.
Another important risk is lag issues. Due to dual EMA smoothing and dual confirmation mechanisms, the strategy may not respond promptly during early trend transitions, missing optimal entry timing or bearing unnecessary drawdowns. This lag is particularly evident in rapidly changing markets.
To mitigate lag issues, consider introducing leading indicators or price action analysis modules, such as monitoring price acceleration changes or key support/resistance breakouts. Additionally, parameter combinations can be optimized to appropriately improve response speed while maintaining strategy stability.
While parameter sensitivity is relatively low, over-optimization risks still exist. Excessive parameter tuning on historical data may lead to poor actual trading performance. Forward-walking analysis and out-of-sample testing are recommended to verify parameter robustness.
Strategy performance under extreme market conditions also requires special attention. During black swan events or liquidity crises, normal price behavior may fail, causing unexpected large losses.
The Twin Range Filter Dynamic Trend Following Strategy has multiple further optimization directions. First is enhancing market environment adaptability. Volatility state classification systems can be introduced, such as ATR-based volatility grading or VIX-like indicator market sentiment analysis. Automatically adjusting strategy parameters based on different market environments - increasing mult1 and mult2 values in high-volatility environments and decreasing these values in low-volatility environments - improves environmental adaptability.
Second is further improving signal quality. Volume-price coordination analysis can be considered - when price breaks through filter lines accompanied by volume expansion, signal credibility increases. Additionally, combining key technical level analysis gives higher weight when breakouts occur near important support/resistance levels.
Dynamic parameter adjustment is another important optimization direction. Current strategy uses fixed period parameters, but market cyclical characteristics change dynamically. Adaptive parameter mechanisms can be introduced, dynamically adjusting per1 and per2 values based on market volatility cycles and trend persistence. For example, extending period parameters in trending markets to reduce noise and shortening them in oscillating markets to improve responsiveness.
Risk management module improvement is also an important optimization direction. Multi-layered risk control mechanisms can be introduced, including single trade risk limits, consecutive loss protection, maximum drawdown control, etc. Position management systems can also be considered, dynamically adjusting position sizes based on signal strength and market environment.
Machine learning technology application is also a promising optimization direction. Machine learning algorithms can optimize parameter selection, signal filtering, and risk control. For example, using genetic algorithms for parameter combination optimization, support vector machines for signal classification, or reinforcement learning for dynamic position management.
The Twin Range Filter Dynamic Trend Following Strategy is an elegantly designed, logically clear trend-following system. Its core advantage lies in effectively filtering market noise while maintaining sensitivity to trend changes through dual filtering mechanisms and adaptive range adjustments. The strategy’s dual confirmation mechanism and continuous counting logic significantly improve signal quality, enabling good performance in trending markets.
However, the strategy has limitations, mainly in adaptability during oscillating markets and lag issues during trend transitions. These problems are not insurmountable - through introducing market environment identification, dynamic parameter adjustment, and multi-layered risk control optimization measures, overall strategy performance can be further enhanced.
This strategy is particularly suitable for traders with technical analysis foundations and risk management experience. In practical application, combining with other technical indicators and fundamental analysis to form more comprehensive trading systems is recommended. Thorough historical backtesting and simulation trading should be conducted to deeply understand strategy performance characteristics in different market environments and develop corresponding risk control measures.
For quantitative traders, this strategy provides an excellent foundational framework for further innovation and optimization. Through continuous research and improvement, this strategy has the potential to become a robust and reliable quantitative trading tool.
/*backtest
start: 2024-05-22 00:00:00
end: 2025-05-20 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"SOL_USDC"}]
*/
//@version=5
strategy("Twin Range Filter Strategy", overlay=true, margin_long=100, margin_short=100, commission_type=strategy.commission.cash_per_contract, commission_value=1.75, use_bar_magnifier=true, process_orders_on_close=true, fill_orders_on_standard_ohlc=true)
// Inputs
source = input(close, "Source")
// Smooth Average Range
per1 = input.int(27, "Fast period", minval=1)
mult1 = input.float(1.5, "Fast range", minval=0.1)
per2 = input.int(55, "Slow period", minval=1)
mult2 = input.float(1.0, "Slow range", minval=0.1)
trail = input.bool(false, "Trail price")
smoothrng(x, t, m) =>
wper = t * 2 - 1
avrng = ta.ema(math.abs(x - x[1]), t)
ta.ema(avrng, wper) * m
smrng1 = smoothrng(source, per1, mult1)
smrng2 = smoothrng(source, per2, mult2)
smrng = (smrng1 + smrng2) / 2
// Range Filter
rngfilt(x, r) =>
rngfilt = x
rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r :
x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r
rngfilt
filt = rngfilt(source, smrng)
upward = 0.0
upward := filt > filt[1] ? nz(upward[1]) + 1 : filt < filt[1] ? 0 : nz(upward[1])
downward = 0.0
downward := filt < filt[1] ? nz(downward[1]) + 1 : filt > filt[1] ? 0 : nz(downward[1])
hband = filt + smrng
lband = filt - smrng
longCond = false
shortCond = false
longCond := source > filt and (source > source[1] or source < source[1]) and upward > 0
shortCond := source < filt and (source < source[1] or source > source[1]) and downward > 0
var int CondIni = 0
CondIni := trail ? longCond ? -1 : shortCond ? 1 : CondIni : longCond ? 1 : shortCond ? -1 : CondIni
long = longCond and CondIni[1] == -1
short = shortCond and CondIni[1] == 1
// Strategy Execution
strategy.entry("Long", strategy.long, when=long)
strategy.entry("Short", strategy.short, when=short)
strategy.close("Long", when=not long)
strategy.close("Short", when=not short)
// Plotting
plot(filt, "Filter", color=color.blue)
plot(hband, "Upper Band", color=color.red)
plot(lband, "Lower Band", color=color.green)
// Alerts
alertcondition(long, "Long", "Long position triggered")
alertcondition(short, "Short", "Short position triggered")