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 Weighted Value Reversion is a mean-reversion trading strategy for MetaTrader 5 that fades price back toward a custom "acceptance value" line built entirely from raw bar geometry (Open, High, Low, Close). Mean reversion is the idea that price tends to snap back toward a fair-value centre after stretching too far away from it. Instead of anchoring to a conventional Simple Moving Average (SMA), Exponential Moving Average (EMA), or Volume Weighted Average Price (VWAP), this strategy computes its own centre of gravity that deliberately ignores the loud, climactic bars that pull ordinary averages off-centre.
The core insight is about weighting. Most fair-value anchors treat every bar equally, so they get dragged around by the very wide "excursion" bars that represent price leaving value — which are exactly the moves a reversion trader wants to fade. Range Weighted Value Reversion instead weights each bar by how quiet it was. A tight, low-range bar (price being accepted by the market) counts near full weight, while a wide, climactic bar (price travelling fast) is pushed toward near-zero weight. The resulting line represents where the market has actually been trading and accepting price, giving a cleaner reference point to revert toward.
This strategy is designed for ranging or balanced market conditions, not trends. It is best suited to traders who want to study how a novel, indicator-free value anchor behaves and how a strategy can gate itself to only fade price inside a range. As with any tool covered here, it is intended as a learning resource for understanding mean-reversion mechanics — not as a shortcut to returns.
How It Works
The strategy evaluates only once per newly closed bar and holds a single position at a time, letting the stop-loss and take-profit manage each trade. Here is the logic in plain English:
- Build the acceptance value line. Over the lookback window (
ValuePeriod), the strategy first measures the average bar range. Each bar's typical price — (High + High + Low + Close divided appropriately, i.e. (High + Low + Close) / 3) — is then weighted by the formulaavgRange² / (range² + avgRange²). Quiet bars dominate the resulting weighted average (the "value"); wide bars barely register. - Measure the trend drift (the ranging gate). Using a least-squares regression of the closing prices across the same window, the strategy calculates the slope, then converts it into a total "window drift" figure. If that drift is larger than
FlatDriftAtrmultiplied by the ATR, the window is considered trending and the strategy stands aside. Reversion needs balance, not trend. - Compute ATR manually. The Average True Range (ATR) — a measure of recent volatility — is calculated directly from the true ranges of closed bars, with no indicator handle. ATR scales both the deviation trigger and the stop distance so the strategy adapts to each instrument's volatility.
- Check the stretch. The strategy measures how far the last closed bar's close sits from the acceptance value. To arm a trade, this deviation must exceed
DeviationAtrmultiplied by the ATR. - Confirm a turn back toward value. A stretch alone is not enough; the last closed bar must also print a reversal candle:
- Long setup: the close is stretched below the value line and the last bar is bullish (close above its open and above the prior close). The strategy signals a BUY, targeting the value line.
- Short setup: the close is stretched above the value line and the last bar is bearish (close below its open and below the prior close). The strategy signals a SELL, targeting the value line.
- Stop-loss logic. The protective stop is placed
StopAtrATRs beyond the entry price — below entry for longs, above entry for shorts — so the risk distance breathes with volatility. - Take-profit logic. The take-profit is the acceptance-value line itself. This directly expresses the reversion thesis: the trade aims to capture the snap-back to where the market has been trading, and no further.
Because the take-profit is the value line and the stop is a fixed ATR multiple, each trade has a clearly defined, self-scaling risk-to-reward profile that the strategy verifies is positive before sending any order.

Strategy Parameters
| Parameter | Default | Min | Max | Description |
|---|---|---|---|---|
| ValuePeriod | 30 | 10 | 100 | Lookback window (in bars) for the range-weighted acceptance-value line and its slope. Larger values create a slower, smoother centre of gravity. |
| AtrPeriod | 14 | 5 | 50 | Number of bars used to compute the ATR that scales the deviation trigger and the stop distance. |
| DeviationAtr | 2.0 | 0.5 | 5.0 | How many ATRs price must be stretched from the value line before a fade is armed. Higher values demand a larger stretch and produce fewer, more selective signals. |
| FlatDriftAtr | 1.5 | 0.2 | 5.0 | Maximum window drift (in ATRs) that still counts as "balance." This is the ranging gate; lower values restrict trading to flatter markets. |
| StopAtr | 1.5 | 0.5 | 5.0 | Protective stop-loss distance beyond the entry, measured in ATRs. |
| Lots | 0.10 | 0.01 | 1.0 | Trade volume in lots per position. |

Recommended Chart Settings
Range Weighted Value Reversion is a general-purpose mean-reversion framework and does not hard-code a specific symbol. A sensible starting point for study is a major forex pair such as EUR/USD or GBP/USD on an intraday timeframe like M15, M30, or H1, where ranging, balanced conditions occur frequently enough to exercise the strategy's fade logic. Mean-reversion approaches generally struggle to find clean setups on strongly trending instruments, so pairs and periods that spend meaningful time consolidating tend to suit this design.
Remember that results will vary considerably across different symbols, timeframes, brokers, and market conditions. Always test on the specific instrument and period you intend to trade, and re-evaluate the DeviationAtr and FlatDriftAtr gates for each market's typical behaviour.
How to Install on MetaTrader 5
- Download the
.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
Strengths of this approach. The range-weighted value line is a genuinely thoughtful attempt to solve a real problem with reversion anchors: ordinary averages are distorted by exactly the excursion bars a fader wants to ignore. By down-weighting wide bars, the acceptance line stays closer to where price has been accepted. The explicit ranging gate (FlatDriftAtr) is another disciplined feature — the strategy actively refuses to fade a trend, which is the classic way mean-reversion systems get hurt. Requiring a confirming turn candle also filters out simply catching a falling knife the moment price stretches.
Known limitations. Mean reversion has a structurally asymmetric risk profile: many small wins targeting the value line can be undone by a few large losses when price breaks out of the range and keeps going. No regime filter is perfect, so some fades will inevitably be armed just as a genuine trend begins. The take-profit at the value line can also be a moving target between the signal bar and the fill, and slippage or spread on entry may erode the already-modest reward. Because only one position is held at a time, the strategy may sit idle for long stretches when markets are quiet or, conversely, when they are strongly trending and the ranging gate keeps it out.
Where it may underperform. Strongly trending, news-driven, or gapping markets are the natural weak spot for any fade-the-stretch design. In those conditions the deviation trigger may fire repeatedly against the prevailing move. This EA is best understood as an educational study of value-based reversion, not as a system to deploy unsupervised.
Risk Management Tips
- Risk a small, fixed fraction per trade. A common educational guideline is to risk no more than 1–2% of account equity on any single position, sizing your lots so the
StopAtrdistance corresponds to that fraction. - Start on a demo account. Run the strategy on a demo or simulated account first to understand how it behaves across different sessions before committing any real capital.
- Understand drawdown. Even a well-designed reversion strategy will experience losing streaks. Study the maximum drawdown you could tolerate and make sure your position sizing reflects it.
- Mind the reward-to-risk balance. Because the take-profit is the value line while the stop is an ATR multiple, some setups may offer only a modest reward relative to risk. Review this ratio before enabling live trading.
- Diversify and supervise. Avoid relying on a single strategy or instrument, and monitor the EA rather than leaving it fully unattended, especially around high-impact news.
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: RangeWeightedValueReversion.ex5 (23 downloads)
- Source Code: RangeWeightedValueReversion.mq5 (22 downloads)
- Documentation: RangeWeightedValueReversion.pdf (26 downloads)