PROTECTED SOURCE SCRIPT
Donchian Breakout Strategy with Dynamic Risk Managment & Pyramid

Donchian Breakout Strategy with Dynamic Risk Management & Pyramiding
Overview
This indicator implements a Donchian Channel breakout system with advanced position management features designed for intraday and swing trading. It combines classic trend-following entry logic with modern risk management techniques including ATR-based stops, breakeven protection, and pyramiding capabilities.
Core Methodology
Entry System
The strategy uses a dual Donchian Channel approach:
20-period Donchian Channel for entry signals: Trades are initiated when price breaks above the 20-bar high (long) or below the 20-bar low (short)
10-period Donchian Channel for exit signals: Positions close when price crosses the opposite 10-bar extreme
This asymmetric channel setup allows trends to develop while providing quicker exits when momentum weakens.
Stop Loss Management
Initial stops are placed using ATR (Average True Range) multipliers, automatically adapting to current market volatility. The default 2.0x ATR creates stops that adjust to changing price action.
Dynamic Stop Features:
Breakeven Protection: Automatically moves stop to entry price once position reaches specified profit (default 1R)
ATR Trailing Stop: Continuously adjusts stop loss based on current ATR, locking in profits as trend continues (1.5x ATR default)
These features work independently or together, preventing premature exits while protecting gains.
Pyramiding Logic
The indicator supports scaled position building during strong trends:
Additional entries trigger every 0.5 ATR of favorable movement (configurable)
Maximum 3 pyramid levels per trend (adjustable 0-10)
Each pyramid references the last entry price, ensuring only genuine continuation gets additional exposure
This approach increases position size when the market confirms trend strength, while limiting total risk through the max pyramids parameter.
What Makes This Different
Unlike basic Donchian indicators, this script provides:
State-aware position tracking that prevents conflicting signals
ATR-normalized risk management that adapts across instruments and volatility regimes
Progressive position sizing that captures extended trends
Dual-mode stop loss combining fixed-risk and trailing components
The combination of breakeven protection and ATR trailing creates a "ratchet effect" where stops move only in favorable direction, never loosening once tightened.
How to Use
Parameters to Adjust:
Entry/Exit Periods: Shorter = more signals, faster exits; Longer = fewer, higher-quality setups
ATR Multiplier: Controls initial risk per trade (2.0 = moderate, 1.5 = tighter, 2.5 = wider)
Pyramid Settings: Increase max pyramids and reduce ATR trigger for aggressive scaling
Stop Management: Toggle breakeven/trailing independently based on market conditions
Visual Elements:
Green/Red triangles: Initial entry signals
Small diamonds: Pyramid additions
X markers: Exit signals (price or stop-based)
Colored lines: Active stop loss levels
Info table: Real-time strategy parameters and position status
Best Practices:
Use on liquid instruments with clear trends
Adjust ATR period (default 14) based on timeframe
Enable trailing stops in trending markets, disable in choppy conditions
Monitor pyramid spacing relative to typical move size
Risk Disclosure
This is an educational indicator showing historical and potential signals. It does not execute trades automatically. Always backtest parameters on your specific instrument and timeframe before live trading. Past performance does not guarantee future results.
Overview
This indicator implements a Donchian Channel breakout system with advanced position management features designed for intraday and swing trading. It combines classic trend-following entry logic with modern risk management techniques including ATR-based stops, breakeven protection, and pyramiding capabilities.
Core Methodology
Entry System
The strategy uses a dual Donchian Channel approach:
20-period Donchian Channel for entry signals: Trades are initiated when price breaks above the 20-bar high (long) or below the 20-bar low (short)
10-period Donchian Channel for exit signals: Positions close when price crosses the opposite 10-bar extreme
This asymmetric channel setup allows trends to develop while providing quicker exits when momentum weakens.
Stop Loss Management
Initial stops are placed using ATR (Average True Range) multipliers, automatically adapting to current market volatility. The default 2.0x ATR creates stops that adjust to changing price action.
Dynamic Stop Features:
Breakeven Protection: Automatically moves stop to entry price once position reaches specified profit (default 1R)
ATR Trailing Stop: Continuously adjusts stop loss based on current ATR, locking in profits as trend continues (1.5x ATR default)
These features work independently or together, preventing premature exits while protecting gains.
Pyramiding Logic
The indicator supports scaled position building during strong trends:
Additional entries trigger every 0.5 ATR of favorable movement (configurable)
Maximum 3 pyramid levels per trend (adjustable 0-10)
Each pyramid references the last entry price, ensuring only genuine continuation gets additional exposure
This approach increases position size when the market confirms trend strength, while limiting total risk through the max pyramids parameter.
What Makes This Different
Unlike basic Donchian indicators, this script provides:
State-aware position tracking that prevents conflicting signals
ATR-normalized risk management that adapts across instruments and volatility regimes
Progressive position sizing that captures extended trends
Dual-mode stop loss combining fixed-risk and trailing components
The combination of breakeven protection and ATR trailing creates a "ratchet effect" where stops move only in favorable direction, never loosening once tightened.
How to Use
Parameters to Adjust:
Entry/Exit Periods: Shorter = more signals, faster exits; Longer = fewer, higher-quality setups
ATR Multiplier: Controls initial risk per trade (2.0 = moderate, 1.5 = tighter, 2.5 = wider)
Pyramid Settings: Increase max pyramids and reduce ATR trigger for aggressive scaling
Stop Management: Toggle breakeven/trailing independently based on market conditions
Visual Elements:
Green/Red triangles: Initial entry signals
Small diamonds: Pyramid additions
X markers: Exit signals (price or stop-based)
Colored lines: Active stop loss levels
Info table: Real-time strategy parameters and position status
Best Practices:
Use on liquid instruments with clear trends
Adjust ATR period (default 14) based on timeframe
Enable trailing stops in trending markets, disable in choppy conditions
Monitor pyramid spacing relative to typical move size
Risk Disclosure
This is an educational indicator showing historical and potential signals. It does not execute trades automatically. Always backtest parameters on your specific instrument and timeframe before live trading. Past performance does not guarantee future results.
Mã được bảo vệ
Tập lệnh này được đăng dưới dạng mã nguồn đóng. Tuy nhiên, bạn có thể sử dụng tự do và không giới hạn – tìm hiểu thêm tại đây.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã được bảo vệ
Tập lệnh này được đăng dưới dạng mã nguồn đóng. Tuy nhiên, bạn có thể sử dụng tự do và không giới hạn – tìm hiểu thêm tại đây.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.