strategy · on price · open source

VWAP Mean Reversion

Deepwick · @deepwickv1Updated 2 Oct 2026▲ 0 users
Running…
Loading chart…

About

VWAP mean reversion long-only: enter when price drops below the session VWAP by the band percentage, exit when it recovers above VWAP.

  • Lower Band % for tighter, more frequent entries.
  • Best on intraday timeframes (1m–1h) where VWAP has clear meaning.
  • Combine with a higher-timeframe trend filter for swing setups.

Source code

//@version=5
strategy("VWAP Mean Reversion", overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=10, commission_type=strategy.commission.percent, commission_value=0.05)
bandPct = input.float(1, "Band %", minval=0.1, maxval=5, step=0.1)
stopPct = input.float(2, "Stop Loss %", minval=0.5, maxval=10, step=0.1)
tpPct = input.float(6, "Take Profit %", minval=0, maxval=20, step=0.1)
v = ta.vwap(hlc3)
lowerBand = v * (1 - bandPct / 100)
upperBand = v * (1 + bandPct / 100)
longSignal = strategy.position_size == 0 and close < lowerBand
exitSignal = strategy.position_size > 0 and close > v
if longSignal
    strategy.entry("Long", strategy.long)
if strategy.position_size > 0
    strategy.exit("Risk", stop=stopPct > 0 ? strategy.position_avg_price * (1 - stopPct / 100) : na, limit=tpPct > 0 ? strategy.position_avg_price * (1 + tpPct / 100) : na)
if exitSignal
    strategy.close("Long", comment="Back to VWAP")
p_VWAP = plot(v, "VWAP", color=color.orange, linewidth=2)
p_Lower_Band = plot(lowerBand, "Lower Band", color=color.new(color.teal, 50), linewidth=1)
p_Upper_Band = plot(upperBand, "Upper Band", color=color.new(color.teal, 50), linewidth=1)
plotshape(longSignal, "Long", style=shape.triangleup, location=location.belowbar, color=color.green, text="L")
plotshape(exitSignal, "Exit", style=shape.triangledown, location=location.abovebar, color=color.red, text="X")
alertcondition(longSignal, "VWAP long entry", "Price dropped below VWAP band")
alertcondition(exitSignal, "VWAP exit", "Price recovered above VWAP")

Comments

No comments yet.

Sign in to comment.