Richard Donchian’s rule was the simplest one in trading: buy the highest high of the last twenty bars. The advanced dc indicator draws those rails and marks the breaks, then adds the two controls the original lacked, namely a distance filter and a minimum gap between marks.
This build ships as a compiled .ex4 for MT4 and .ex5 for MT5; the screenshots below come from EURUSD H1.
| Platforms | MT4 (.ex4) + MT5 (.ex5) |
|---|---|
| Chart window | Main price chart |
| Plots | 5: DC upper, DC lower, DC mid, BUY (upper rail break), SELL (lower rail break) |
| Alerts | popup, push notification, email, sound |
| Inputs | 20 |
What appears on the chart
Three lines and two marks on price.
`DC upper` traces dodger blue at width 2.
`DC lower` traces orange red beside it.
`DC mid` traces goldenrod at width 1.
`BUY (upper rail break)` prints lime using arrow 233.
`SELL (lower rail break)` prints red using arrow 234.
- DC upper: line, width 2
- DC lower: line, width 2
- DC mid: line, width 1
- BUY (upper rail break): arrow, width 2, arrow code 233
- SELL (lower rail break): arrow, width 2, arrow code 234

Following the source
Highest and lowest
`DcPeriod` `20` is the window. The highest high across it becomes the upper rail, the lowest low the lower one, and the midpoint between them draws the third line.
Pushing the window back
`OffsetBars` `1` excludes the current bar from its own comparison. Without that a bar could never break a rail it helped define, which is why one is the classic setting.
The optional distance test
`UseAtrFilter` ships off. Turned on, a break must clear the rail by `AtrMult` `0.25` of an `AtrPeriod` `14` range before the mark prints.
Reading it correctly
A flat rail means no new extreme for twenty bars.
A stepping rail means price keeps making them.
Marks land on the bar that cleared a rail.
`MinBarsBetween` `3` keeps repeat marks apart.
`SignalOnClosedBarsOnly` `true` waits for the close.
`ArrowOffsetPts` `30` sets the gap from the candle.
Alert channels in this build: popup, push notification, email and sound, one message per closed bar.
A rail break is the event that reports. `EnableAlerts` decides whether it speaks and the popup route is on by default. Mobile delivery, mail delivery and the desktop file named by `SoundFile` all start closed, one message per closed bar.
Every Advanced DC Indicator input
Core settings
| Setting | What it does | Default |
|---|---|---|
DcPeriod |
Donchian lookback (bars). Bars behind each rail, `20`. | 20 |
OffsetBars |
Bars the window is pushed back (1 = classic). Bars the window steps back, `1`. | 1 |
UseAtrFilter |
Require the break to clear an ATR multiple. Require a break to clear by a distance, `false`. | off |
AtrPeriod |
ATR period for the filter. Window behind that distance, `14`. | 14 |
AtrMult |
Break distance in ATR multiples. Range multiple a break must clear, `0.25`. | 0.25 |
SignalOnClosedBarsOnly |
Test closed bars only (false = intra-bar). Wait for the bar to finish, `true`. | on |
MinBarsBetween |
Minimum bars between same-side arrows. Bars held between same-side marks, `3`. | 3 |
Display settings
| Setting | What it does | Default |
|---|---|---|
ArrowOffsetPts |
Arrow offset from the bar (points). Distance a mark keeps from the bar, `30`. | 30 |
UpperColor |
Upper rail colour. | dodger blue |
LowerColor |
Lower rail colour. | orange red |
MidColor |
Mid line colour. | goldenrod |
BuyColor |
BUY arrow colour. | lime |
SellColor |
SELL arrow colour. | red |
Alert settings
| Setting | What it does | Default |
|---|---|---|
MaxBars |
History bars to scan (0 = all). | 1500 |
EnableAlerts |
Master alert switch. Decides whether a rail break speaks, `true`. | on |
EnablePopup |
Popup alert. The popup route, on by default, `true`. | on |
EnablePushNotify |
Push notification to mobile. | off |
EnableEmail |
Email alert. | off |
EnableSound |
Sound alert. | off |
SoundFile |
Sound file. | alert.wav |

Markets and timeframes
Twenty bars is a short window by Donchian’s own standards; he worked on daily charts. EURUSD H1 is the reference chart and gives several rail breaks a week. On M5 the rails churn. On D1 twenty bars covers a month of trade.
What it will not tell you
Rails made of extremes break on the bar that sets one.
In a range price clips both rails in turn.
The distance filter ships off, so breaks pass unchecked.
A rail says where price has been, not where it goes.
Copy the compiled Advanced DC Indicator file into your MQL4/Indicators folder, and the MT5 build into MQL5/Indicators, then restart the terminal and drag it onto a chart. The step-by-step guide with screenshots is at how to install MT4 and MT5 indicators.
Background reading on the method behind the Advanced DC Indicator: Donchian channel on Wikipedia, Price Channels at StockCharts ChartSchool.
Download the Advanced DC Indicator for MT4 and MT5
The zip holds the compiled Advanced DC Indicator build for MT4 and MT5, plus a short README. Compiled files only, no source. Enter your email below and the download link arrives in your inbox.
Download this indicator free
Enter your email and the file is yours. You also get the full MT4 and MT5 library.
FAQ
What does OffsetBars 1 prevent?
A bar breaking a rail it defined itself. Pushing the window back one bar means the upper rail reflects the previous twenty bars only, so the current bar can genuinely clear it or fail to.
When is UseAtrFilter worth switching on?
When marginal breaks are the problem. It demands the close clear the rail by a quarter of the current range, which discards the brush-past breaks that a bare rail comparison always produces.
Where does DcPeriod 20 put the DC mid line?
Exactly halfway between the two rails, which is the middle of the twenty-bar range. It moves only when one extreme changes, so it steps rather than curving the way an average would.
Why does MinBarsBetween default to 3?
Because price making a run of new extremes would otherwise mark every single bar. Three bars of spacing keeps the chart showing the start of a move rather than each step of it.
Are results guaranteed?
No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Advanced DC Indicator as one input. Always backtest before trading live.
Authoritative references
- Learn more about technical indicators.
