Donchian Breakout Channel with ATR Trailing Stop
Info
The Donchian Breakout Channel with ATR Trailing Stop is a Indicator for MetaTrader 5 that donchian breakout channel with atr trailing stopthis indicator combines a donchian channel with an atr trailing stop line. The channel on each bar represents the highest high and the lowest low of N_Channel bars ending two bars prior, ensuring the bar tested for a breakout is not part of its own channel.
Usage
This tool is typically used for breakout trading when price moves beyond key support/resistance levels.
Platform
This Indicator works exclusively on MetaTrader 5 (both build 600+ and newer versions).
Setup
Place the downloaded file in MQL5/Indicators folder via File ? Open Data Folder in MetaTrader 5.
How to Install and Use Donchian Breakout Channel with ATR Trailing Stop
1. Installation: Place your file in the MQL/Indicators folder via "Open Data Folder" and restart your terminal.
2. Loading: Find the indicator in the Navigator, drag it onto your chart, and configure the input parameters in the popup window.
3. Customization: Press Ctrl+I to open the indicator list, select your tool, and click "Properties" to change colors, levels, or visual styles.
4. Updating: Replace the old file in the Indicators folder with the new version and restart the platform to apply changes.
Frequently Asked Questions
Q: Why is my indicator not showing? A: Verify the file is in the MQL/Indicators folder, or try right-clicking the "Indicators" tree in the Navigator and clicking "Refresh."
Q: Do custom indicators slow down the platform? A: Too many complex indicators can impact performance; remove unused ones via the "Indicator List" (Ctrl+I).
Q: Can I use MT4 indicators on MT5? A: No, MQL4 and MQL5 are distinct languages; ensure the indicator is compiled specifically for your platform version.
What this tool does
Donchian Breakout Channel with ATR Trailing StopThis indicator combines a Donchian channel with an ATR trailing stop line.
Typical Use Case
This Indicator excels in automated trading and technical analysis on MetaTrader 5.
Compatible Platform & Setup
This Indicator works on MetaTrader 5. Place the file in the MQL5/Indicators folder and restart the terminal.
Description & Settings
Related: Gold Donchian Breakout Channel (Non-Repainting with HTF Trend Filter) - another powerful indicator for MetaTrader 5 traders.
Donchian Breakout Channel with ATR Trailing StopAlso recommended: Session Range Boxes with Asia Breakout Alert for MT4/MT5 - similar indicator with strong performance on MetaTrader 5.
This indicator combines a Donchian channel with an ATR trailing stop line. The channel on each bar represents the highest high and the lowest low of N_Channel bars ending two bars prior, ensuring the bar tested for a breakout is not part of its own channel. A breakout is identified when the previous bar closes above the upper line or below the lower line, with an arrow placed on the subsequent bar.
Following a breakout, the trailing stop line is initiated at the close price, adjusted by Trail_ATR multiplied by the ATR value. This line will only move in the direction of the breakout as long as no new breakout occurs. If a bar closes across this line, the indicator line disappears until the next breakout. The line appears green after an upward breakout and red after a downward breakout. On each bar following a close outside the channel, the line is reset based on that bar's closing price.
The channel calculation and breakout determination utilize only closed bars. The trailing stop value for the bar currently forming is based on its live price and is finalized upon closure. Arrows are positioned 0.4 ATR below the low or above the high of the bar. A single arrow symbol is used for both upward and downward breakouts, with the direction inferred from its placement relative to the bar.
Input Parameters
N_Channel
- The period in bars for the Donchian channel calculation (default is 40).
Trail_ATR
- The multiplier of the ATR used to set the distance of the trailing stop line (default is 8.0).
ATR_Period
- The period for the Average True Range (ATR) calculation (default is 14).
ShowArrows
- A setting to display or hide the breakout arrows (default is true).
Buffers:
0 - Upper channel line
1 - Lower channel line
2 - Trailing stop line
3 - Trailing stop color index (0 for upward, 1 for downward)
4 - Breakout arrows
The empty value for plots is 0. This indicator does not place or manage trades.
Example visualization: Donchian channel, breakout arrows, and ATR trailing stop on EURUSD H1 timeframe in 2026.
You may also like: Chart Pattern Breakout Indicator - excellent alternative for indicator users on MetaTrader 5.
Source Code
#property copyright "RobotFX"
#property link "https://robotfx.org"
#property version "1.10"
#property description "This code is educational. Feel free to use, modify and upgrade as you wish. Visit ROBOTFX.ORG for professional trading tools"
#property indicator_chart_window
#property indicator_buffers 5
#property indicator_plots 4
#property indicator_label1 "Donchian upper"
#property indicator_type1 DRAW_LINE
#property indicator_color1 clrDodgerBlue
.......
⚠ Limitations & Risk Warning
- This tool is provided for educational and testing purposes only.
- Past performance does not guarantee future results.
- Trading involves substantial risk of loss. Use on a demo account first.
- Results may vary depending on market conditions, broker, and settings.
- We recommend thorough backtesting and forward testing before using with real funds.