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 Vwap Deviation Reversion strategy is a mean-reversion trading system built around VWAP (Volume Weighted Average Price), the single most widely watched intraday reference line used by institutional desks. VWAP is the average price of an instrument over a period, weighted by traded volume — large funds benchmark their order fills against it, which is part of why price tends to be repeatedly pulled back toward the VWAP line throughout a session. This strategy is designed to identify moments when price has stretched unusually far away from that average and may be due to "snap back."
Rather than chasing trends, the Vwap Deviation Reversion approach fades over-extension: it looks for bars that have closed well above or below VWAP and then begin to reverse. To measure "how far is too far," the strategy wraps deviation bands around a rolling, volume-weighted VWAP, calculated from the volume-weighted standard deviation of typical price. When a bar closes outside a band and momentum looks exhausted, the strategy treats VWAP itself as a magnet and targets a return to the mean.
This system is best understood as a learning tool for studying mean reversion and volatility-adaptive risk, not as a shortcut to results. It suits traders who want to see how VWAP, RSI (Relative Strength Index, a momentum oscillator), and ATR (Average True Range, a volatility measure) can be combined into a single rules-based filter. Because every component is self-scaling, it is a useful case study in how to build an entry, a structural target, and a volatility-based stop that all adapt to current market conditions.
How It Works
The strategy acts only once per newly closed bar on the chart's primary timeframe, so signals are evaluated on completed price action rather than flickering intrabar data. On each closed bar it rebuilds a rolling, volume-weighted VWAP and its deviation bands over the most recent VwapPeriod bars.
The core building blocks are:
- Rolling VWAP — the volume-weighted average of typical price
(High + Low + Close) / 3over the last N bars. This is the "mean" the strategy expects price to revert toward. - Deviation bands — an upper and lower band placed at
VWAP ± (BandMult × standard deviation), where the standard deviation is itself volume-weighted. Wider volatility automatically widens the bands. - RSI confirmation — the strategy requires momentum to look exhausted before fading a move, so a stretch isn't faded while it's still accelerating.
- ATR-based stop — the protective stop distance is set to a multiple of recent ATR, so it breathes with volatility.
A long (buy) setup signals when all three of these align on a freshly closed bar:
- The bar closes below the Lower band — price is over-stretched to the downside.
- RSI is below the oversold level — momentum appears exhausted.
- The bar is bullish (close above open) — the first visible sign of a snap-back.
When a long signals, the strategy buys at the Ask, sets the take-profit at VWAP (the mean it expects price to revisit), and places the stop one ATR multiple below the entry.
A short (sell) setup is the mirror image:
- The bar closes above the Upper band — price is over-stretched to the upside.
- RSI is above the overbought level.
- The bar is bearish (close below open).
When a short signals, the strategy sells at the Bid, targets VWAP, and places the stop one ATR multiple above the entry.
Two additional filters keep the system disciplined:
- Minimum reward-to-risk filter — if price has already drifted so close to VWAP that the potential move to target is smaller than
MinRewardRisktimes the ATR stop distance, the setup is rejected as not worth the risk. - Spread filter — new entries are skipped when the current spread (in points) is wider than
MaxSpreadPoints, avoiding poor fills during thin or volatile conditions.
Finally, the strategy holds only one position per magic number at a time. Once in a trade, the ATR stop and the VWAP target manage the exit entirely — there is no averaging in or pyramiding.

Strategy Parameters
| Parameter | Default | Min | Max | Description |
|---|---|---|---|---|
| VwapPeriod | 30 | 10 | 120 | Rolling window, in bars, used to compute the volume-weighted VWAP and its deviation bands. |
| BandMult | 2.0 | 1.0 | 4.0 | Band width as a multiple of the volume-weighted standard deviation. Higher values demand a larger stretch before a fade. |
| RsiPeriod | 14 | 5 | 30 | RSI lookback used to confirm momentum exhaustion at the band. |
| RsiOversold | 35 | 10 | 45 | RSI must be at or below this level to allow a long fade. |
| RsiOverbought | 65 | 55 | 90 | RSI must be at or above this level to allow a short fade. |
| AtrPeriod | 14 | 5 | 30 | ATR lookback used to measure recent volatility for the stop. |
| AtrStopMult | 1.5 | 0.5 | 4.0 | Stop distance as a multiple of ATR, placed beyond the entry. |
| MinRewardRisk | 0.8 | 0.3 | 3.0 | Minimum reward-to-risk ratio; setups with a VWAP target too close relative to the stop are rejected. |
| MaxSpreadPoints | 80 | 5 | 300 | Maximum allowable spread, in points, for a new entry. |
| Lots | 0.10 | 0.01 | 1.0 | Fixed order volume in lots. |
| Magic | 7731 | 0 | 9,999,999 | Unique magic number identifying this EA's positions. |

Recommended Chart Settings
The Vwap Deviation Reversion strategy was designed with liquid intraday markets in mind — a major FX pair or an index such as EURUSD or US500 on the M5 to M15 timeframes, which is the natural home of VWAP reversion day-trading. These markets tend to have the consistent volume and orderly oscillation around VWAP that the strategy's logic relies on.
The expert advisor runs on whatever timeframe the chart is set to, so you can study its behavior across different timeframes. Keep in mind that results will vary considerably across different instruments and market conditions — a setting that behaves well on one symbol or volatility regime may behave very differently on another. Treat any configuration as a starting point for your own testing rather than a finished recipe.
How to Install on MetaTrader 5
- Download the .ex5 file 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
Every approach has trade-offs, and understanding them is part of trading well.
Strengths of this approach:
- It is fully self-scaling. Bands adapt to volatility through the standard deviation, the stop adapts through ATR, and the take-profit is a genuine structural reference (VWAP) rather than an arbitrary fixed distance.
- It uses multiple confirmations — band stretch, RSI exhaustion, and a reversal candle — so it does not blindly fade every band touch.
- The reward-to-risk and spread filters add discipline by rejecting low-quality setups before they are taken.
Known limitations:
- Mean-reversion systems are inherently vulnerable to strong trends. When price breaks away from VWAP and keeps going, a "stretch" can become more stretched, and fading it repeatedly may produce a run of stop-outs.
- The strategy uses a rolling VWAP over N bars, not a true session-anchored VWAP that resets each day. This is a deliberate engineering choice for a single symbol/timeframe engine, but it behaves differently from the session VWAP many discretionary traders watch.
- It relies on tick volume as a proxy for real traded volume, which is standard in retail FX but is not the same as exchange volume.
- Performance is sensitive to parameter choices, and conditions that suit reversion (range-bound, balanced markets) may give way to trending phases where it underperforms.
The honest takeaway: this is a thoughtfully constructed mean-reversion framework that historically tends to perform best in balanced, range-bound conditions and may struggle in persistent trends. Study it, test it, and understand why it signals before drawing any conclusions.
Risk Management Tips
Sound risk management matters more than any single strategy. As you study this EA, keep these general principles in mind:
- Position sizing: Size each trade so that a loss is survivable. Many educational sources suggest risking no more than 1–2% of account equity per trade.
- Use a demo account first: Run the strategy on a demo or simulated account until you fully understand its behavior across different market conditions.
- Understand drawdown: Even a logically sound strategy can experience extended losing streaks. Know the maximum drawdown you are willing to tolerate before you begin.
- Account for costs: Spread, commission, and slippage all affect outcomes, especially on lower timeframes — the spread filter helps, but real-world costs still apply.
- Avoid over-optimization: Tuning parameters until they fit past data perfectly often produces results that do not hold up going forward. Aim for robust settings, not perfect ones.
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: VwapDeviationReversion.ex5 (2 downloads)
- Source Code: VwapDeviationReversion.mq5 (1 downloads)
- Documentation: VwapDeviationReversion.pdf (2 downloads)