Skip to content

Free MT5 Expert Advisor

VWAP Reversion EA

MT5 Expert Advisor that fades intraday stretches beyond k standard deviations of the daily VWAP and targets a return to VWAP.

Mean reversionv1.0MetaTrader 5 (MQL5) Compiles with 0 errors Stop-loss on every trade
Strategy
Buys when a bar closes more than k standard deviations below the daily VWAP and turns up, and sells when a bar closes more than k deviations above VWAP and turns down. The take-profit is VWAP itself.
Risk model
1% of balance per trade (configurable), ATR-based stop-loss on every order, one position at a time, optional end-of-day exit

What it does

VWAP (volume-weighted average price) is the average price of the day weighted by activity. VWAP Reversion EA treats it as the day's fair value: when price is stretched far away from it, the EA bets on a move back toward it, and it closes everything by the end of the trading window.

How it works

VWAP resets at the start of each server day. For every closed bar of the day the EA takes the typical price (high + low + close) ÷ 3 and weights it by the bar's tick volume, because spot forex has no central exchange volume:

  • VWAP = Σ(typical price × volume) ÷ Σ(volume)
  • Deviation = square root of [Σ(typical price² × volume) ÷ Σ(volume) − VWAP²]

On every new bar, once at least 12 bars of the day exist:

  • Buy: the last close is below VWAP − 2 × deviation and, with the reversal option on, the bar closed above its open.
  • Sell: the last close is above VWAP + 2 × deviation and the bar closed below its open.
  • Stop-loss: 1.5 × ATR(14) from entry. Take-profit: the VWAP value at the signal.
  • Reward check: skipped if VWAP is closer than 0.8 × the stop distance.
  • Time exit: any open trade is closed when the trading hours end.

The EA refuses to start on charts above H1, because a daily VWAP needs intraday bars.

How to use it

Run it on M5 to M30 during liquid hours. With the default 8–20 server-time window it skips the thin hours around the daily reset. Stretched moves on news days often keep going, so many traders also avoid high-impact releases on the Economic Calendar. The forex sessions lesson explains why activity changes through the day.

Settings

InputDefaultWhat it changes
Entry band k2.0How stretched price must be
Bars of the day required12Warm-up after the daily reset
Reversal candle requiredtrueConfirmation of the turn
ATR period / Stop-loss (x ATR)14 / 1.5Stop size
Min reward vs stop0.8Skips setups with a close target
End-of-day exittrueFlattens at the end hour
Risk per trade / Fixed lots1.0% / 0Position sizing
Max spread (points)30Spread filter
Trading start / end hour8 / 20Server-time window
Break-even / Trailingon / offStop management

Limitations

Tick volume is only a proxy for traded volume. The VWAP resets at the broker's server midnight, which may not match the session you care about. On trend days price can stay beyond the band for hours. The target is fixed at entry while VWAP keeps moving.

Before you run it live

Test it in the Strategy Tester with real-tick data, because intraday results are very sensitive to spread, then on a demo account. Confirm your broker's server time, set the trading window accordingly and keep the risk per trade small. Past behavior does not guarantee future results.

Key inputs

Key inputs of VWAP Reversion EA
InputDefaultDescription
Entry band: VWAP +/- k standard deviations2.0How far from VWAP a close must be to count as stretched.
Bars of the day required before trading12Lets VWAP settle after the daily reset.
Signal candle must close back toward VWAPtrueRequires a bullish candle for buys and a bearish one for sells.
Stop-loss distance (x ATR)1.5Stop size as a multiple of ATR(14).
Skip if distance to VWAP < this x stop0.8Minimum reward relative to risk.
Close open trades at the end hour (intraday only)trueFlattens any trade when the trading window ends.

Educational tools, not advice. Automated trading can lose money quickly. Indicators and Expert Advisors describe price; they do not predict it, and past behaviour does not guarantee future results. Test everything on a demo account first and never risk money you cannot afford to lose. See our disclaimer.

Keep exploring

Related mt5 expert advisors