Blog / Strategy
Strategy

Donchian Midline Reversion

Disclaimer: This article is for educational and informational purposes only. It does not constitute financial or investment advice. Trading forex and CFDs carries significant risk of loss. Past performance of any strategy — including backtests — does not guarantee future results. Never trade with money you cannot afford to lose.

What Is This Strategy?

The Donchian Midline Reversion strategy is a range-based mean-reversion system that combines the Donchian Channel with the Relative Strength Index (RSI) to fade failed breakouts. Mean reversion is a trading style built on the idea that when price stretches to an extreme, it often snaps back toward an average or "fair" value rather than continuing in the same direction. The Donchian Channel — a band drawn from the highest high and lowest low over a set number of bars — defines the boundaries of the recent range, and the midpoint of that channel becomes the reversion target the strategy aims for.

Rather than chasing momentum, this expert advisor (EA) waits for a false break: a bar that pierces the outer edge of the channel but then closes back inside it. That rejection, paired with an RSI reading at an extreme, is treated as evidence that the breakout has failed and that price may rotate back toward the middle of the range. To avoid trading in dead, compressed conditions where mean reversion tends to whipsaw, the strategy also applies a minimum channel-width filter measured in Average True Range (ATR) units — ATR being a common gauge of recent volatility.

As a learning tool, the Donchian Midline Reversion is well suited to traders who want to study how range-trading logic, oscillator confirmation, and volatility filters combine into a single rules-based system. It is a strategy analysis, not a shortcut — the value here is in understanding why each condition exists and how they interact, so you can evaluate whether this style of approach fits your own testing and research.

How It Works

The strategy evaluates conditions once per completed bar and holds only one position at a time. Long and short logic are fully symmetric — mirror images of each other. Here is how the strategy signals a trade:

Building the range:

The volatility filter:

Long entry — the strategy signals a buy when:

Short entry — the strategy signals a sell when:

Stop-loss logic:

Take-profit logic:

Donchian midline reversion strategy
Illustrative example of the strategy’s entry and exit logic — not real trading results.

Strategy Parameters

Parameter Default Min Max Description
ChannelPeriod 20 10 60 Number of bars used to build the Donchian channel that defines the range and midline.
RsiPeriod 14 7 28 Lookback length for the RSI oscillator that confirms an extreme.
RsiOversold 30 15 40 RSI level marking oversold for longs; the overbought level is derived as 100 − this value.
AtrPeriod 14 7 28 Lookback length for the ATR used in the width filter and stop buffer.
MinWidthAtr 2.0 1.0 5.0 Minimum channel width, in ATR units, required before a trade is allowed.
SlAtrMult 1.0 0.5 3.0 ATR multiple added beyond the rejected extreme to place the stop-loss.
Lots 0.10 0.01 1.0 Fixed trade volume in lots.
Donchian midline reversion strategy — MQL5 source code

Recommended Chart Settings

This EA is designed as a general-purpose range mean-reversion tool and works on standard forex symbols. A common starting point for studying this style is a major currency pair such as EUR/USD on an intraday timeframe like the H1 (1-hour) chart, where ranges and false breaks are frequent enough to generate signals without excessive noise. The default parameters (a 20-bar channel, 14-period RSI and ATR) are tuned around this kind of setting.

Because mean-reversion behavior differs across instruments and sessions, results will vary considerably across different symbols, timeframes, and market conditions. Trending markets, in particular, can behave very differently from the ranging conditions this strategy targets. Always test any configuration on your own broker's data before drawing conclusions.

How to Install on MetaTrader 5

What to Consider Before Using This EA

Every strategy has strengths and trade-offs, and understanding both is part of learning to evaluate systems objectively.

Strengths of this approach:

Known limitations:

This is a tool for study and structured testing — not a set-and-forget solution. Treat it as a framework to understand, question, and stress-test.

Risk Management Tips

Sound risk management matters more than any single entry rule. As you study this or any strategy, keep these general principles in mind:

Risk Warning

Trading foreign exchange, CFDs, and other leveraged financial instruments involves substantial risk of loss and is not suitable for all investors. The strategies and tools discussed on this page are provided for educational purposes only and do not constitute financial advice, investment recommendations, or solicitation to trade. Always consult a qualified financial adviser before making trading decisions. Past backtest performance is not indicative of future results.

Downloads

← Back to Blog