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?
Range Percentile Reversion is a counter-trend, mean-reversion strategy that trades the edges of a horizontal price range using a percentile position calculation paired with a rejection-wick candlestick filter. Unlike most range tools, it relies on no oscillator and no moving average. Instead, the only "indicator" is the raw geometry of the last several bars treated as a support-and-resistance band, plus the Average True Range (ATR) — a standard volatility measure — used purely to size the stop-loss.
The core idea is simple to picture. For every freshly closed candle, the strategy measures how high or low that candle's closing price sits inside the recent high-low band. A close pinned near the top of the band is "overbought within the range," while a close pinned near the bottom is "oversold within the range." Being at the edge alone is not a signal, however — ranges are frequently broken. So the strategy adds a confirmation requirement: a same-bar rejection wick that shows the edge was probed and then refused by the market. Only then does it fade the move back toward the middle of the range.
As a learning tool, Range Percentile Reversion is well suited to traders who want to study how mean-reversion logic behaves in rotational, sideways markets. It demonstrates how a strategy can quantify "stretched" price without a traditional indicator, how candlestick rejection can act as a trigger, and how volatility-based stops are constructed. It is designed for rotational conditions and is best treated as a study of range mechanics rather than a profit opportunity.
How It Works
The strategy evaluates one decision per newly closed bar and holds a maximum of one position at a time. Here is the logic in plain English:
- Build the range band. It scans the last
RangeLookbackclosed bars and records the highest high (bandHigh) and lowest low (bandLow). The distance between them is the band; the midpoint between them is the midline, which acts as the fair-value magnet the trade targets. - Measure percentile position. It calculates
pos = (close − bandLow) / (bandHigh − bandLow). A value near 1.0 means the close is at the top of the range; a value near 0.0 means it is at the bottom. - Demand a rejection wick. The strategy inspects the same candle's wicks relative to its full range. A short setup needs a dominant upper wick (buyers rejected the highs); a long setup needs a dominant lower wick (sellers rejected the lows). The wick must be at least
WickRatioof the bar's total range. - Short signal: the strategy signals a short when
posis greater than or equal toExtremePctand the upper wick is large enough. This may indicate buyers were turned away at the range top. - Long signal: the strategy signals a long when
posis less than or equal to1 − ExtremePctand the lower wick is large enough. This may indicate sellers were turned away at the range bottom. - Take-profit logic. Both directions target the band midline — the natural resting point of a balanced range. A short fades down toward it; a long fades up toward it.
- Stop-loss logic. Stops sit just beyond the band extreme, where the range thesis would be invalidated. A short places its stop above
bandHigh; a long places its stop belowbandLow. Each stop is padded byAtrStopMult × ATRso ordinary noise does not clip the trade prematurely. - Sanity checks. Before sending an order, the strategy confirms that both the calculated risk and reward are positive — price must actually sit on the correct side of the midline for the fade to make sense. If not, no trade is taken.

Strategy Parameters
| Parameter | Default | Min | Max | Description |
|---|---|---|---|---|
| Lots | 0.10 | 0.01 | 1.00 | Fixed trade size in lots for each position. Keep this small while learning. |
| RangeLookback | 20 | 10 | 60 | Number of recent closed bars used to build the high-low support/resistance band. |
| ExtremePct | 0.85 | 0.70 | 0.95 | Percentile threshold that defines a range edge. 0.85 means a close in the top 15% (or bottom 15%) qualifies as an extreme. |
| WickRatio | 0.40 | 0.20 | 0.70 | Minimum rejection-wick size as a fraction of the candle's full range. Higher values demand a more pronounced rejection. |
| AtrPeriod | 14 | 7 | 30 | Lookback length for the Average True Range, the volatility measure used to pad the stop-loss. |
| AtrStopMult | 0.50 | 0.20 | 1.50 | Multiplier applied to ATR to extend the stop beyond the band extreme, giving the trade breathing room. |

Recommended Chart Settings
Range Percentile Reversion was built with EUR/USD or AUD/USD on the M15 or M30 timeframe in mind, because these pairs and timeframes tend to spend meaningful time in rotational, range-bound sessions where mean-reversion logic is most relevant. That said, the strategy is symbol- and timeframe-agnostic — it runs on whatever instrument and period you attach it to. Results will vary considerably across different market conditions, and a setting that looks balanced on one pair may behave very differently on another. Always study its behavior on your chosen market before drawing any conclusions.
How to Install on MetaTrader 5
- Download the
RangePercentileReversion.ex5file from the link below. - Copy it to your MT5
MQL5\Expertsfolder. - Restart MetaTrader 5 or refresh the Navigator panel.
- Drag the EA onto a chart matching the recommended symbol and timeframe.
- Configure the input parameters and enable Algo Trading.
What to Consider Before Using This EA
Like every approach, Range Percentile Reversion has clear strengths and equally clear limitations worth understanding.
Strengths. The logic is transparent and easy to reason about — there is no opaque indicator stack, just range geometry and a candlestick filter. The rejection-wick requirement helps avoid blindly fading every touch of an edge, and the ATR-padded stop adapts to current volatility rather than using a fixed distance. Targeting the midline gives the strategy a defined, mechanical exit instead of an open-ended hope.
Known limitations. This is a counter-trend method, which means its natural weakness is a trending or breakout market. When price genuinely breaks out of a range, the strategy will keep trying to fade the move, and a rejection wick can appear right before a strong continuation. In those conditions it may underperform or take a series of losing trades. The range band is also backward-looking — it is built from past bars, so a fresh expansion in volatility can place stops in awkward locations. Because the take-profit is fixed at the midline, the reward on any single trade is bounded, and a few stops beyond the band extreme can outweigh several midline targets if the win rate slips.
Treat this EA as a way to learn how range mechanics, percentile positioning, and candlestick rejection interact — not as a turnkey solution. Forward-test it thoroughly and observe how it copes when a quiet range finally breaks.
Risk Management Tips
Sound risk management matters far more than any single entry rule. Keep these general principles in mind as you study this strategy:
- Risk a small, fixed percentage per trade. A common educational guideline is to risk no more than 1–2% of your account balance on any one position, and to size your lots accordingly rather than using a large default.
- Start on a demo account. Run the EA in a simulated environment first so you can observe its behavior across trending and ranging conditions without financial consequences.
- Understand drawdown. Even a logically sound strategy will experience losing streaks. Know the maximum drawdown you are willing to tolerate before you ever go live, and stop if it is breached.
- Avoid over-leveraging. Leverage amplifies losses as much as gains. Use it conservatively, especially while you are still evaluating how the strategy performs.
- Review regularly. Markets change. A range-reversion approach that suits a quiet period may need to be paused or re-evaluated when conditions turn trend-heavy.
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
- Expert Advisor: RangePercentileReversion.ex5 (5 downloads)
- Source Code: RangePercentileReversion.mq5 (5 downloads)
- Documentation: RangePercentileReversion.pdf (3 downloads)