strategy · on price · open source
VWAP Mean Reversion strategy
VWAP Mean Reversion is a free open-source strategy by @deepwick. VWAP mean reversion long-only: enter when price drops below the session VWAP by the band… Deepwick Script runs a subset of Pine Script.
Running…
Loading chart…
What VWAP Mean Reversion does
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
Deepwick Script, a subset of Pine Script · read-only
//@version=6
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)
colorMid = input.color("color.orange", "Color Mid")
colorMid2 = input.color("color.teal", "Color Mid2")
colorUp = input.color("color.green", "Color Up")
colorDown = input.color("color.red", "Color Down")
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=colorMid, linewidth=2)
p_Lower_Band = plot(lowerBand, "Lower Band", color=color.new(colorMid2, 50), linewidth=1)
p_Upper_Band = plot(upperBand, "Upper Band", color=color.new(colorMid2, 50), linewidth=1)
plotshape(longSignal, "Long", style=shape.triangleup, location=location.belowbar, color=colorUp, text="L")
plotshape(exitSignal, "Exit", style=shape.triangledown, location=location.abovebar, color=colorDown, text="X")
alertcondition(longSignal, "VWAP long entry", "Price dropped below VWAP band")
alertcondition(exitSignal, "VWAP exit", "Price recovered above VWAP")
No comments yet.
Sign in to comment.