Trend Breakout Trading Strategy Based on Donchian Channel and Moving Average
This strategy is a trend following trading system that combines the Donchian Channel and 200-period Simple Moving Average (SMA). It identifies potential long and short opportunities by observing price breakouts of…

Overview
This strategy is a trend following trading system that combines the Donchian Channel and 200-period Simple Moving Average (SMA). It identifies potential long and short opportunities by observing price breakouts of the Donchian Channel in conjunction with SMA trends. The strategy also incorporates a dynamic stop-loss mechanism based on the channel midline for risk control.
Strategy Principles
The core logic of the strategy is based on the following key elements:
- Uses 20-period calculation for Donchian Channel's upper, lower, and middle bands
- Incorporates 200-period SMA to determine overall trend direction
- Entry signals:
- Long signal triggers when price breaks above the Donchian Channel upper band and is above SMA200
- Short signal triggers when price breaks below the Donchian Channel lower band and is below SMA200
- Stop-loss settings:
- Long position stop-loss is set at 45% below the channel midline
- Short position stop-loss is set at 45% above the channel midline
Strategy Advantages
- Effective trend following: Successfully captures medium to long-term trends by combining Donchian Channel breakouts with SMA200 confirmation
- Reasonable risk control: Dynamic stop-loss mechanism based on channel midline adapts to market volatility
- Simple parameter settings: Only requires two main parameters - channel period and moving average period, reducing over-optimization risk
- Clear strategy logic: Entry and exit conditions are well-defined, easy to understand and execute
- High adaptability: Applicable to different trading instruments and timeframes
Strategy Risks
- Sideways market risk: May generate frequent false breakout signals in ranging markets, leading to consecutive stops
- Slippage risk: Actual execution prices may significantly differ from signal prices in fast-moving markets
- Trend reversal risk: Potential for large drawdowns during major trend shifts
- Parameter sensitivity: Strategy performance significantly affected by channel and moving average period selection
Risk control suggestions:
- Recommend cross-validation with other technical indicators
- Consider adding trend strength filters
- Implement dynamic position sizing
- Regular parameter review and optimization
Strategy Optimization Directions
Signal optimization:
- Add volume confirmation mechanism
- Introduce trend strength indicators
- Consider price pattern analysis
Stop-loss optimization:
- Research optimal stop-loss percentage
- Add trailing stop mechanism
- Consider volatility-adaptive stops
Position management optimization:
- Implement volatility-based dynamic position sizing
- Add scaled entry and exit mechanisms
Timing optimization:
- Add market environment recognition
- Optimize trading time filters
Summary
This strategy combines the classic Donchian Channel and moving average indicators to create a trend following system with clear logic and controllable risk. Its main advantages lie in clear signals and reasonable risk control, though performance may be suboptimal in ranging markets. The strategy has significant optimization potential through adding volume confirmation, improving stop-loss mechanisms, and introducing dynamic position management. Traders are advised to maintain strict risk control in live trading and optimize the strategy based on specific trading instruments and market conditions.
Source Pine Script
/*backtest
start: 2024-02-21 00:00:00
end: 2024-03-18 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"SOL_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ardhankurniawan
//@version=5
strategy("Donchian Channel Strategy with SMA 200 and Custom SL", overlay=true)
// Parameters
length = 20
smaLength = 200 // Changed SMA to 200
// Calculate Donchian Channel
upper = ta.highest(high, length)
lower = ta.lowest(low, length)
mid = (upper + lower) / 2 // Mid Line
// Calculate SMA 200
sma200 = ta.sma(close, smaLength)
// Plot Donchian Channel, SMA 200, and Mid Line
plot(upper, color=color.green, linewidth=2, title="Upper Line")
plot(lower, color=color.red, linewidth=2, title="Lower Line")
plot(mid, color=color.orange, linewidth=1, title="Mid Line")
plot(sma200, color=color.blue, linewidth=2, title="SMA 200")
// Long and Short logic based on SMA 200
longCondition = upper > ta.highest(upper[1], length) and close > sma200
shortCondition = lower < ta.lowest(lower[1], length) and close < sma200
// Calculate Stop Loss for Long and Short based on new conditions
longSL = mid - 0.45 * (mid - lower) // SL for Long when price crosses down mid line
shortSL = mid + 0.45 * (upper - mid) // SL for Short when price crosses up mid line
// Enter Long or Short position
if (longCondition)
strategy.entry("Long", strategy.long)
if (shortCondition)
strategy.entry("Short", strategy.short)
// Place Stop Loss
strategy.exit("Exit Long", from_entry="Long", stop=longSL)
strategy.exit("Exit Short", from_entry="Short", stop=shortSL)
Published by ianzeng123 on the FMZ strategy square · last modified 2025-02-27. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Trend-Breakout-Trading-Strategy-Based-on-Donchian-Channel-and-Moving-Average.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.
Related specs
- Momentum Breakout Trading Strategy 435896Pine Script · Breakout · 1d
- Multi Indicator Trend Breakout Strategy with Dynamic Stop LossPine Script · Breakout · 1d
- Multi Condition Donchian Channel Momentum Breakout StrategyPine Script · Breakout · 1d
- Dynamic Volume Enhanced Donchian Channel Trend Breakout StrategyPine Script · Breakout · 3h
- Momentum Multi Indicator Trend Following Strategy Donchian Channel with SuperTrend and Volume Filter Entry SystemPine Script · Breakout · 1d
- Adaptive Multi Period Trading Strategy Based on Wave Trend Momentum BreakoutPine Script · Breakout · 2h