Trading Strategy
VWAP Strategy
A momentum-based trading strategy using Volume Weighted Average Price (VWAP) to identify trend direction and institutional trade execution quality.
Institutional Trading Benchmark
VWAP (Volume Weighted Average Price) is the gold standard for institutional traders to measure execution quality and identify market direction. This strategy combines VWAP crossovers with RSI confirmation and a 200 EMA trend filter to capture high-probability momentum moves while avoiding false signals.
Momentum Type
4h Chart Timeframe
Intermediate Complexity
Intraday Best Market
Signal Logic
Long (Buy)
Price crosses above VWAP while above the 200 EMA, with RSI in oversold zone (<30) for confirmation.
Short (Sell)
Price crosses below VWAP while below the 200 EMA, with RSI in overbought zone (>70) for confirmation.
Implementation
//@version=6
strategy("VWAP Strategy", overlay=true, initial_capital=1000000, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
// ==========================================
// 🔹 INPUTS
// ==========================================
// Group: VWAP Settings
grp_vwap = "VWAP Settings"
use_session_reset = input.bool(true, "Reset at Session Start", group=grp_vwap)
// Group: Trend Filter
grp_trend = "Trend Filter"
use_trend = input.bool(true, "Use Trend Filter (EMA 200)", group=grp_trend)
ema_len = input.int(200, "Trend EMA Length", minval=1, group=grp_trend)
// Group: Confirmation
grp_confirm = "Confirmation"
use_rsi = input.bool(true, "Use RSI Filter", group=grp_confirm)
rsi_len = input.int(14, "RSI Length", minval=1, group=grp_confirm)
rsi_oversold = input.int(30, "RSI Oversold", minval=0, maxval=50, group=grp_confirm)
rsi_overbought = input.int(70, "RSI Overbought", minval=50, maxval=100, group=grp_confirm)
// Group: Risk Management
grp_risk = "Risk Management"
atr_len = input.int(14, "ATR Length", minval=1, group=grp_risk )
sl_mult = input.float(2.0, "Stop Loss (ATR Multiplier)", step=0.1, group=grp_risk)
tp_ratio = input.float(2.0, "Risk:Reward Ratio", step=0.1, group=grp_risk)
// ==========================================
// 🔹 CALCULATIONS
// ==========================================
// VWAP calculation - uses built-in with session reset
vwap_val = ta.vwap(close)
// EMA for trend filter
ema_val = ta.ema(close, ema_len)
// RSI for confirmation
rsi_val = ta.rsi(close, rsi_len)
// ATR for risk management
atr_val = ta.atr(atr_len)
// Trend conditions
price_above_vwap = close > vwap_val
price_below_vwap = close < vwap_val
trend_up = use_trend ? close > ema_val : true
trend_down = use_trend ? close < ema_val : true
// ==========================================
// 🔹 STRATEGY LOGIC
// ==========================================
// Long Entry:
// 1. Price crosses above VWAP (bullish momentum)
// 2. Price above EMA (uptrend) if filter enabled
// 3. RSI in oversold zone (optional confirmation)
long_signal = price_above_vwap and price_below_vwap[1] and trend_up
if use_rsi and long_signal
long_signal := rsi_val < rsi_oversold
// Short Entry:
// 1. Price crosses below VWAP (bearish momentum)
// 2. Price below EMA (downtrend) if filter enabled
// 3. RSI in overbought zone (optional confirmation)
short_signal = price_below_vwap and price_above_vwap[1] and trend_down
if use_rsi and short_signal
short_signal := rsi_val > rsi_overbought
// ==========================================
// 🔹 EXECUTION & RISK MANAGEMENT
// ==========================================
if long_signal
strategy.entry("Long", strategy.long, comment="L | VWAP")
if short_signal
strategy.entry("Short", strategy.short, comment="S | VWAP")
// Risk management with ATR
if strategy.position_size > 0
stop_level = strategy.position_avg_price - (atr_val * sl_mult)
profit_level = strategy.position_avg_price + (atr_val * sl_mult * tp_ratio)
strategy.exit("Exit Long", "Long", stop=stop_level, limit=profit_level, comment_loss="SL", comment_profit="TP")
if strategy.position_size < 0
stop_level = strategy.position_avg_price + (atr_val * sl_mult)
profit_level = strategy.position_avg_price - (atr_val * sl_mult * tp_ratio)
strategy.exit("Exit Short", "Short", stop=stop_level, limit=profit_level, comment_loss="SL", comment_profit="TP")
// ==========================================
// 🔹 VISUALS
// ==========================================
// Plot VWAP
plot(vwap_val, "VWAP", color=color.new(color.purple, 0), linewidth=2)
// Plot EMA
plot(use_trend ? ema_val : na, "Trend EMA", color=color.new(color.orange, 0), linewidth=2)
// Plot Signals
plotshape(long_signal, title="Long Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY", textcolor=color.white)
plotshape(short_signal, title="Short Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL", textcolor=color.white)
// Background color for trend
bgcolor(price_above_vwap ? color.new(color.green, 95) : color.new(color.red, 95))
// VWAP zone fill
fill(plot(vwap_val), plot(close), top_color=color.new(color.green, 80), bottom_color=color.new(color.red, 80), title="VWAP Zone")