
The Dynamic Breakout WMA-Filtered Donchian Channel Trading Strategy is a quantitative trading system focused on capturing trend-driven breakouts. This strategy combines the Donchian Channel low with a Weighted Moving Average (WMA) as a filter, entering long positions when the Donchian low crosses above the WMA and exiting when the price falls back and crosses below the WMA (or reaches a preset take-profit level). The strategy is specifically designed for the 2025 calendar year and executes trades based on true OHLC data regardless of chart style (including Heikin-Ashi), ensuring accurate backtest results. The strategy starts with an initial capital of 1,000 AUD, deploys 100% of available funds per trade, and does not allow pyramiding.
The core principles of this strategy are based on the interaction between the Donchian Channel and the Weighted Moving Average:
Donchian Channel Low: Forms a dynamic support line by calculating the lowest price within a specified lookback period. The formula used is ta.lowest(real_low, donchian_len).
Weighted Moving Average (WMA): Applied to real closing prices, giving higher weight to recent prices to reflect current price momentum. Calculated using ta.wma(real_close, wma_len).
Entry Signal: Triggered when the Donchian low crosses above the WMA (ta.crossover(donLow, wma)) and the time is within the 2025 range. This crossover indicates a breakout from a compressed volatility range with confirmation from an uptrending WMA.
Exit Signal: Comprises three scenarios:
ta.crossunder(donLow, wma)) and the WMA is no longer rising, indicating stalled momentum.True Price Execution: All indicator calculations are based on the underlying OHLC data of the chart, obtained through the request.security() function, ensuring that the strategy executes based on real price data even on Heikin-Ashi or other styled charts.
Through this design, the strategy aims to capture breakout upward movements following volatility compression, while using the WMA as a trend confirmation filter to reduce false signals.
After an in-depth analysis of the code, the strategy demonstrates the following significant advantages:
Trend Following and Breakout Combination: By combining the Donchian Channel low with the WMA, it captures price breakouts while ensuring alignment with the long-term trend direction, improving signal quality.
Flexible Take-Profit Mechanism: The adjustable take-profit parameter allows traders to set profit targets according to different market environments and personal risk preferences, enhancing strategy adaptability.
True OHLC Data Application: The strategy executes based on real price data regardless of chart style, eliminating the interference of chart styling on backtest results and improving strategy reliability.
Trend Confirmation Mechanism: The exit condition not only considers price crossover but also verifies whether the WMA has stopped rising, avoiding premature exits from strong trends during short-term pullbacks.
Integrated Capital Management: The strategy incorporates initial capital and position size settings, facilitating comprehensive evaluation of strategy performance, including the equity growth curve.
Parameter Adjustability: Core parameters (Donchian length, WMA length, take-profit percentage) are all adjustable, enabling the strategy to adapt to different trading instruments and timeframes.
Time Filtering: The explicit time range limitation (year 2025) helps optimize the strategy for specific market environments, avoiding trading under unsuitable market conditions.
Despite its reasonable design, the strategy still poses the following risks that traders should be aware of:
Single Direction Limitation: The strategy only executes long trades, potentially missing opportunities or facing extended inactive periods in continuously declining markets. Consider adding short logic to address bidirectional markets.
Parameter Sensitivity: The choice of Donchian length and WMA length significantly impacts strategy performance. Inappropriate parameter settings may lead to excessive false signals or missed important trading opportunities. Parameters should be optimized through backtesting under different market conditions.
Market Specificity: The code comments note that default parameters are optimized for Temple & Webster on ASX 30-minute charts, which may not be suitable for all markets and timeframes. Parameters need to be re-optimized for specific trading instruments.
Time Limitation Risk: The strategy is restricted to execution within the 2025 calendar year. If the market performs poorly during this period, it may affect overall returns. Consider extending the time range or adding adaptive time filters.
Take-Profit Setting Risk: Fixed percentage take-profit may exit strong trends too early in high-volatility markets or set targets too far to reach in low-volatility markets. Consider dynamically adjusting take-profit levels based on market volatility.
Drawdown Control Absence: The strategy lacks an explicit stop-loss mechanism and may endure significant drawdowns before crossover signals appear. Consider adding maximum drawdown limits or ATR-based stop-loss mechanisms.
Based on an in-depth analysis of the code, here are several possible optimization directions:
Bidirectional Trading Logic: Add short trading capability, especially when the Donchian Channel high crosses below the WMA and the WMA is declining. This would allow the strategy to profit in declining markets as well.
Dynamic Parameter Adjustment: Implement a mechanism to automatically adjust Donchian length and WMA length based on market volatility. For example, use shorter Donchian lengths in high-volatility environments and longer periods in low-volatility environments.
Stop-Loss Mechanism Addition: Introduce ATR (Average True Range) based stop-losses, or set maximum allowable drawdown percentages to limit losses on individual trades.
Multi-Timeframe Confirmation: Add higher timeframe trend confirmation, executing trades only when aligned with the larger trend direction, reducing the risk of counter-trend trading.
Volume Filter: Add a volume confirmation mechanism, requiring breakout signals to be accompanied by increased volume, improving signal reliability.
Risk-Reward Optimization: Implement variable take-profit/stop-loss ratios, dynamically adjusting based on market conditions, setting more distant take-profit targets when trends are strong.
Partial Profit Strategy: Implement staged exit logic, allowing partial position closing at different profit targets, both securing partial profits and maintaining participation in trends.
Machine Learning Integration: Use machine learning algorithms to optimize parameter selection or predict which market conditions the strategy is more likely to succeed in, thus implementing adaptive trading rules.
Optimizing these aspects can not only improve the robustness and adaptability of the strategy but also expand its application range, maintaining its competitiveness across different market environments.
The Dynamic Breakout WMA-Filtered Donchian Channel Trading Strategy represents a carefully designed quantitative trading approach that combines trend-following and breakout trading principles to capture potential significant upward movements following volatility compression. The core advantages of the strategy lie in its use of true price data, trend confirmation mechanisms, and flexible parameter settings, allowing it to adapt to different trading environments.
However, the strategy also faces challenges such as single-direction trading, parameter sensitivity, and the lack of comprehensive risk management. Through enhancements like bidirectional trading capability, dynamic parameter adjustment, improved stop-loss mechanisms, and multi-timeframe confirmation, the strategy has the potential to become a more comprehensive and robust trading system.
For quantitative traders, this approach of combining technical indicators with explicit execution rules provides a structured framework that is both suitable for direct application and can serve as a foundation for developing more complex trading systems. Most importantly, traders should thoroughly backtest and optimize strategy parameters according to specific market conditions and personal risk preferences to achieve optimal performance.
/*backtest
start: 2024-06-09 00:00:00
end: 2025-06-08 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Donchian x WMA Crossover (2025 Only, Adjustable TP, Real OHLC)", overlay=true, initial_capital=1000, currency=currency.AUD, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
// === INPUTS ===
donchian_len = input.int(7, title="Donchian Length")
wma_len = input.int(62, title="WMA Length")
take_profit_perc = input.float(0.01, title="Take Profit (decimal)", minval=0.0001, step=0.0001)
// === TIME FILTER: Calendar Year 2025 ===
start2025 = timestamp("UTC", 2025, 1, 1, 0, 0)
end2025 = timestamp("UTC", 2025, 12, 31, 23, 59)
in_2025 = time >= start2025 and time <= end2025
// === REAL OHLC FOR THIS CHART’S TIMEFRAME ===
res = timeframe.period
real_close = request.security(syminfo.tickerid, res, close)
real_low = request.security(syminfo.tickerid, res, low)
// === INDICATORS ===
donLow = ta.lowest(real_low, donchian_len)
wma = ta.wma(real_close, wma_len)
// === TREND CHECK ===
wma_up = wma > wma[1]
// === SIGNALS ===
enter = ta.crossover(donLow, wma) and in_2025
crossEx = ta.crossunder(donLow, wma)
exit_tp = strategy.position_size > 0 and real_close >= strategy.position_avg_price * (1 + take_profit_perc)
exit_x = crossEx and not wma_up
exit_all = (exit_tp or exit_x) or not in_2025
// === EXECUTION ===
if enter
strategy.entry("Long", strategy.long)
if exit_all
strategy.close("Long")
// === PLOTS ===
plot(donLow, title="Donchian Low (real)", color=color.gray, linewidth=2)
plot(wma, title="WMA (real)", color=color.blue, linewidth=2)
plot(strategy.position_size > 0
? strategy.position_avg_price * (1 + take_profit_perc)
: na, title="TP Level", color=color.green, linewidth=1, style=plot.style_linebr)