Blog / Strategy
Strategy

Volume Weighted Median 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 Volume Weighted Median Reversion strategy is a mean-reversion system built around a robust fair-value anchor: the volume-weighted median of price over a rolling window of recent bars. Mean reversion is the idea that when price stretches unusually far from a central "fair" level, it tends to snap back toward that level. Instead of using a simple moving average or a VWAP (volume-weighted average price) as its reference, this strategy uses the volume-weighted median — the price level at which half of the traded volume sits above and half below. That distinction is the whole point of the design.

Why the median rather than the mean? A VWAP is an average, so a single climactic bar with enormous range and volume can drag the "fair value" toward an extreme exactly when you most want a stable reference. The median is naturally resistant to that: one outlier bar barely moves the level at which volume is balanced. Weighting the median by tick volume (rather than taking a plain price median) turns it into a liquidity-anchored equilibrium — a genuine volume balance point rather than a purely geometric midpoint. The strategy then measures how far price has stretched from this anchor using the Average True Range (ATR), a standard volatility gauge, so its over-extension threshold self-scales to current market conditions.

As a learning tool, this strategy is well suited to traders who want to study range-trading and volume-based fair-value concepts. It is designed for balanced, ranging markets, not trends, and it includes an explicit regime filter that stands aside during directional runs. If you are interested in how robust statistics (medians), volume weighting, and volatility normalization can be combined into a single disciplined rule set, this is an instructive example to examine on a demo account.

How It Works

The strategy evaluates its logic once per newly closed bar and only ever holds one position at a time. When flat, it looks for three conditions to line up before it acts.

volume weighted median reversion MT5
Illustrative example of the strategy’s entry and exit logic — not real trading results.

Strategy Parameters

Parameter Default Min Max Description
MedianPeriod 40 10 150 Rolling window (bars) used to compute the volume-weighted median fair value.
StretchAtrMult 1.8 0.5 5.0 Over-extension required: the bar must close at least this × ATR away from the VWM.
RegimeLookback 20 5 80 Number of bars back over which the VWM's own drift is measured for the regime gate.
FlatRegimeMult 1.5 0.2 5.0 Fade only when the VWM has drifted less than this × ATR over RegimeLookback bars (flat anchor).
AtrPeriod 14 5 40 Lookback length for the ATR volatility calculation.
AtrStopMult 1.6 0.5 5.0 Stop-loss distance, expressed as this × ATR beyond the entry.
MinRewardRisk 0.7 0.2 3.0 Minimum reward-to-risk ratio; setups closer than this to fair value are rejected.
MaxSpreadPoints 80 5 400 Skip new entries when the current spread (points) is wider than this.
Lots 0.10 0.01 1.0 Order volume in lots.
Magic 8123 0 9,999,999 Magic number used to identify and manage this EA's positions.
volume weighted median reversion MT5 — MQL5 source code

Recommended Chart Settings

This strategy runs on a single timeframe — whatever chart you attach it to — because every calculation uses the primary symbol and period. Its natural home is a liquid FX major or a major index on the M5 to H1 timeframes, where volume-balance reversion tends to be most pronounced and tick-volume data is meaningful. Balanced, range-bound sessions suit the logic best; strongly trending or news-driven conditions are exactly what the flat-regime gate is designed to sit out. Remember that results will vary considerably across different symbols, sessions, and market conditions, so treat any chosen setting as a starting point for your own testing rather than a fixed recommendation.

How to Install on MetaTrader 5

What to Consider Before Using This EA

The main strength of this approach is the robustness of its fair-value anchor. By using a volume-weighted median rather than an average, the reference level is far less sensitive to single climactic bars — a common weakness of VWAP-based fades. The explicit regime filter and the snap-back confirmation add discipline that many naive mean-reversion systems lack, and the ATR-scaled thresholds keep the logic consistent across changing volatility.

That said, every mean-reversion method shares a structural limitation: it is designed to fade extremes, so it can perform poorly when a market stops ranging and begins to trend strongly. The flat-regime gate reduces but does not eliminate this risk, because a market can transition from balanced to trending faster than the lookback can detect. Because the take-profit is fixed at the VWM and the stop is a multiple of ATR, individual losing trades can be larger than individual winners if the reward-to-risk filter is set loosely. The strategy also depends on tick-volume data, which is a proxy for real traded volume in decentralized forex and may behave differently across brokers. Finally, it takes only one position at a time, so it may sit idle for long stretches while waiting for its three conditions to align. Study these trade-offs on historical data and a demo account before drawing any conclusions.

Risk Management Tips

Sound risk management matters more than any single indicator setting. Consider the following general principles as you study this strategy:

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