What is VWAP (Daily)?
VWAP (Volume Weighted Average Price) is a crucial benchmark used by institutional traders and market makers to determine the average price of an asset, adjusted for its trading volume, throughout the trading day. Unlike a simple moving average, VWAP gives more weight to prices at which more volume was traded, making it a more accurate representation of the true average price participants paid for the asset.
The "Daily" aspect is critical: VWAP resets at the beginning of each trading session, accumulating data only for that specific day. This makes it an intraday indicator, primarily used for:
- Fair Value Assessment: Price trading around VWAP is considered "fair value" for the day.
- Execution Benchmark: Institutional traders often aim to execute their orders at or better than VWAP to demonstrate efficient trading.
- Support/Resistance: VWAP frequently acts as a dynamic support or resistance level.
- Trend Confirmation: Price staying above VWAP often indicates an intraday uptrend, while price staying below indicates a downtrend.
In Pine Script, the daily VWAP is a highly utilized tool for short-term trading strategies, providing actionable insights into market sentiment and price efficiency.
Components and Calculation
The calculation of VWAP is cumulative throughout the trading day and resets at the start of each new day:
- Typical Price (TP): For each bar (e.g., each minute, 5-minute, or 15-minute bar within the day), calculate its typical price:
`TP = (High + Low + Close) / 3` - TP * Volume (TPV): Multiply the typical price of the bar by its volume:
`TPV = TP * Volume` - Cumulative TPV: Sum the `TPV` values from the beginning of the trading day up to the current bar.
`Cumulative TPV = Sum(TPV) for the day` - Cumulative Volume: Sum the `Volume` values from the beginning of the trading day up to the current bar.
`Cumulative Volume = Sum(Volume) for the day` - VWAP Formula: Divide the Cumulative TPV by the Cumulative Volume.
`VWAP = Cumulative TPV / Cumulative Volume`
Crucially, all these cumulative sums reset to zero at the start of every new trading day, making VWAP a powerful intraday tool.
Basic Daily VWAP Implementation in Pine Script
Pine Script v5 provides a convenient built-in function `ta.vwap()` for calculating VWAP. It automatically handles the daily reset when used on intraday timeframes.
//@version=5
indicator("My Daily VWAP", overlay=true, timeframe="D") // overlay=true to plot on price chart. timeframe="D" is key for daily reset.
// Calculate Daily VWAP using the built-in function
// ta.vwap() automatically handles the typical price (hlc3) and volume, and resets daily.
dailyVwap = ta.vwap(close, volume) // By default, `ta.vwap` uses `hlc3` for the source if not specified.
// Plot the VWAP line
plot(dailyVwap, title="Daily VWAP", color=color.purple, linewidth=2)
// Optional: Add Standard Deviation Bands around VWAP (similar to Bollinger Bands)
// These are often called VWAP Bands or Standard Deviation Bands.
// They help identify significant deviations from the daily average price.
stdDevLength = input.int(20, title="StdDev Lookback (for VWAP Bands)", minval=1)
stdDevMultiplier1 = input.float(1.0, title="StdDev Multiplier 1", minval=0.1, step=0.1)
stdDevMultiplier2 = input.float(2.0, title="StdDev Multiplier 2", minval=0.1, step=0.1)
// Custom VWAP logic with daily reset
var float sum_tp_volume = 0.0
var float sum_volume = 0.0
var float sum_sq_diff_volume = 0.0
if ta.change(time("D"))
sum_tp_volume := 0.0
sum_volume := 0.0
sum_sq_diff_volume := 0.0
tp = (high + low + close) / 3
sum_tp_volume := sum_tp_volume + (tp * volume)
sum_volume := sum_volume + volume
currentDailyVwap = sum_volume != 0 ? sum_tp_volume / sum_volume : dailyVwap
if not na(currentDailyVwap) and volume > 0
sum_sq_diff_volume := sum_sq_diff_volume + (math.pow(tp - currentDailyVwap, 2) * volume)
stdDevVwap = sum_volume != 0 ? math.sqrt(sum_sq_diff_volume / sum_volume) : 0.0
upperBand1 = currentDailyVwap + (stdDevVwap * stdDevMultiplier1)
lowerBand1 = currentDailyVwap - (stdDevVwap * stdDevMultiplier1)
upperBand2 = currentDailyVwap + (stdDevVwap * stdDevMultiplier2)
lowerBand2 = currentDailyVwap - (stdDevVwap * stdDevMultiplier2)
// Plot VWAP Bands
plot(upperBand1, title="Upper Band 1", color=color.new(color.blue, 50), linewidth=1, style=plot.style_stepline)
plot(lowerBand1, title="Lower Band 1", color=color.new(color.blue, 50), linewidth=1, style=plot.style_stepline)
plot(upperBand2, title="Upper Band 2", color=color.new(color.navy, 70), linewidth=1, style=plot.style_stepline)
plot(lowerBand2, title="Lower Band 2", color=color.new(color.navy, 70), linewidth=1, style=plot.style_stepline)
// Fill between bands for visual clarity
fill(upperBand1, lowerBand1, color.new(color.blue, 95))
fill(upperBand2, lowerBand1, color.new(color.navy, 98))
Practical Daily VWAP Trading Strategies
1. Mean Reversion to VWAP
Price often tends to revert to the VWAP, especially in range-bound or consolidating intraday markets. Traders can fade moves away from VWAP, expecting a return to the average.
- Buy Signal: Price pulls back and touches or briefly penetrates below VWAP, especially if accompanied by signs of support (e.g., bullish candlestick patterns, volume spikes). Target the VWAP or upper band.
- Sell Signal: Price rallies and touches or briefly penetrates above VWAP, especially if accompanied by signs of resistance (e.g., bearish candlestick patterns, low volume on rally). Target the VWAP or lower band.
//@version=5
strategy("VWAP Mean Reversion Strategy", overlay=true, initial_capital=10000)
// Daily VWAP (auto-resets)
dailyVwap = ta.vwap(close, volume)
plot(dailyVwap, "Daily VWAP", color=color.purple, linewidth=2)
// VWAP Bands for mean reversion zones (manual daily reset logic)
var float sum_tp_volume = 0.0
var float sum_volume = 0.0
var float sum_sq_diff_volume = 0.0
if ta.change(time("D"))
sum_tp_volume := 0.0
sum_volume := 0.0
sum_sq_diff_volume := 0.0
tp = (high + low + close) / 3
sum_tp_volume := sum_tp_volume + (tp * volume)
sum_volume := sum_volume + volume
currentDailyVwap = sum_volume != 0 ? sum_tp_volume / sum_volume : dailyVwap
if not na(currentDailyVwap) and volume > 0
sum_sq_diff_volume := sum_sq_diff_volume + (math.pow(tp - currentDailyVwap, 2) * volume)
stdDevVwap = sum_volume != 0 ? math.sqrt(sum_sq_diff_volume / sum_volume) : 0.0
// Inputs for band multipliers
stdDevMultiplierEntry = input.float(1.0, "Entry Band Multiplier", minval=0.1, step=0.1)
stdDevMultiplierExit = input.float(0.5, "Exit Band Multiplier (Target)", minval=0.1, step=0.1)
stopLossMultiplier = input.float(2.5, "Stop Loss Multiplier (relative to StdDev)", minval=0.1, step=0.1)
lowerBandEntry = currentDailyVwap - (stdDevVwap * stdDevMultiplierEntry)
upperBandEntry = currentDailyVwap + (stdDevVwap * stdDevMultiplierEntry)
lowerBandTarget = currentDailyVwap + (stdDevVwap * stdDevMultiplierExit)
upperBandTarget = currentDailyVwap - (stdDevVwap * stdDevMultiplierExit)
// Plot bands for visualization
plot(lowerBandEntry, "Lower Entry Band", color=color.green, style=plot.style_stepline)
plot(upperBandEntry, "Upper Entry Band", color=color.red, style=plot.style_stepline)
// Long Entry Condition
longCondition = close > lowerBandEntry and close[1] <= lowerBandEntry[1] and close > open
if (longCondition)
strategy.entry("Long Reversion", strategy.long)
// Short Entry Condition
shortCondition = close < upperBandEntry and close[1] >= upperBandEntry[1] and close < open
if (shortCondition)
strategy.entry("Short Reversion", strategy.short)
// Long Exit
longStopPrice = strategy.position_avg_price - (stdDevVwap * stopLossMultiplier)
strategy.exit("Long Reversion Exit", from_entry="Long Reversion", profit=upperBandTarget, stop=longStopPrice)
// Short Exit
shortStopPrice = strategy.position_avg_price + (stdDevVwap * stopLossMultiplier)
strategy.exit("Short Reversion Exit", from_entry="Short Reversion", profit=lowerBandTarget, stop=shortStopPrice)
2. VWAP Trend Confirmation
In a strong intraday trend, price will consistently stay on one side of the VWAP. VWAP itself will also be sloping in the direction of the trend.
- Uptrend Confirmation: Price is consistently trading above VWAP, and VWAP is sloping upwards. Pullbacks to VWAP can be considered buying opportunities.
- Downtrend Confirmation: Price is consistently trading below VWAP, and VWAP is sloping downwards. Rallies to VWAP can be considered selling opportunities.
//@version=5
strategy("VWAP Trend Following Strategy", overlay=true)
dailyVwap = ta.vwap(close, volume)
plot(dailyVwap, "Daily VWAP", color=color.purple, linewidth=2)
// Define bullish and bearish VWAP slopes for trend confirmation
vwapSlopePeriod = input.int(5, "VWAP Slope Lookback", minval=1)
isVwapUptrend = dailyVwap > dailyVwap[vwapSlopePeriod]
isVwapDowntrend = dailyVwap < dailyVwap[vwapSlopePeriod]
// Long Entry: Price crosses above VWAP, and VWAP is trending up
longCondition = ta.crossover(close, dailyVwap) and isVwapUptrend
// Short Entry: Price crosses below VWAP, and VWAP is trending down
shortCondition = ta.crossunder(close, dailyVwap) and isVwapDowntrend
if (longCondition)
strategy.entry("Long Trend", strategy.long)
if (shortCondition)
strategy.entry("Short Trend", strategy.short)
// Exit: Price crosses back over VWAP, indicating trend weakness
strategy.close("Long Trend", when=ta.crossunder(close, dailyVwap))
strategy.close("Short Trend", when=ta.crossover(close, dailyVwap))
3. VWAP Anchor Points / Breakouts
VWAP can act as a crucial anchor point for breakouts. A decisive break from VWAP, especially on higher volume, can signal the start of a strong directional move.
- Bullish Breakout: Price rallies significantly above VWAP from a consolidation below it, accompanied by a notable increase in volume.
- Bearish Breakout: Price declines significantly below VWAP from a consolidation above it, accompanied by a notable increase in volume.
- Failed Breakout / Rejection: Price approaches VWAP but is rejected with high volume, indicating strong institutional defense of that level.
//@version=5
strategy("VWAP Breakout Strategy", overlay=true)
dailyVwap = ta.vwap(close, volume)
plot(dailyVwap, "Daily VWAP", color=color.purple, linewidth=2)
// Using VWAP Bands to define breakout zones
var float sum_tp_volume = 0.0
var float sum_volume = 0.0
var float sum_sq_diff_volume = 0.0
if ta.change(time("D"))
sum_tp_volume := 0.0
sum_volume := 0.0
sum_sq_diff_volume := 0.0
tp = (high + low + close) / 3
sum_tp_volume := sum_tp_volume + (tp * volume)
sum_volume := sum_volume + volume
currentDailyVwap = sum_volume != 0 ? sum_tp_volume / sum_volume : dailyVwap
if not na(currentDailyVwap) and volume > 0
sum_sq_diff_volume := sum_sq_diff_volume + (math.pow(tp - currentDailyVwap, 2) * volume)
stdDevVwap = sum_volume != 0 ? math.sqrt(sum_sq_diff_volume / sum_volume) : 0.0
stdDevMultiplierBreakout = input.float(1.5, "Breakout Band Multiplier", minval=0.1, step=0.1)
minVolumeMultiplier = input.float(1.5, "Min Volume Multiplier for Breakout", minval=1.0, step=0.1)
upperBandBreakout = currentDailyVwap + (stdDevVwap * stdDevMultiplierBreakout)
lowerBandBreakout = currentDailyVwap - (stdDevVwap * stdDevMultiplierBreakout)
plot(upperBandBreakout, "Upper Breakout Band", color=color.gray, style=plot.style_stepline)
plot(lowerBandBreakout, "Lower Breakout Band", color=color.gray, style=plot.style_stepline)
// Calculate average volume for confirmation
avgVolume = ta.sma(volume, 20)
isHighVolume = volume > avgVolume * minVolumeMultiplier
// Long Breakout: Price crosses above upper breakout band with high volume
longBreakoutCondition = close > upperBandBreakout and close[1] <= upperBandBreakout[1] and isHighVolume
// Short Breakout: Price crosses below lower breakout band with high volume
shortBreakoutCondition = close < lowerBandBreakout and close[1] >= lowerBandBreakout[1] and isHighVolume
if (longBreakoutCondition)
strategy.entry("Long Breakout", strategy.long)
if (shortBreakoutCondition)
strategy.entry("Short Breakout", strategy.short)
// Basic exit: Price crosses back over VWAP, or hits opposite band
strategy.close("Long Breakout", when=close < dailyVwap or close < lowerBandBreakout)
strategy.close("Short Breakout", when=close > dailyVwap or close > upperBandBreakout)
Optimizing Daily VWAP Performance
To get the most from Daily VWAP in Pine Script:
- Timeframe Alignment: VWAP is an intraday indicator. It works best on intraday charts (e.g., 1-minute, 5-minute, 15-minute). On daily charts, it simply represents `hlc3` for the day and isn't typically used for dynamic signals.
- Combine with Volume Analysis: Since VWAP is volume-weighted, its signals are highly enhanced by confirming volume. High volume on a breakout from VWAP or a bounce off VWAP adds conviction.
- VWAP Bands: Utilize standard deviation bands around VWAP (as implemented in the examples) to identify overextended price levels relative to the volume-weighted average. Prices outside the ±1 or ±2 standard deviation bands can signal overbought/oversold conditions or strong momentum.
- Multi-Timeframe Context: Although VWAP is intraday, consider the broader trend from a higher timeframe. If the daily trend is bullish, favor long setups around VWAP bounces or breakouts.
- Institutional Levels: Be aware that large institutional players often use VWAP to evaluate their execution quality. This means their buying/selling activity can be concentrated around VWAP, making it a self-fulfilling prophecy.
- Anchor VWAP (Advanced): For multi-day analysis, consider implementing "Anchor VWAP" starting from a specific event (e.g., quarterly earnings, significant low/high) which *doesn't* reset daily. This is a more advanced concept not covered by the `ta.vwap()` built-in.
Common Daily VWAP Pitfalls
- Not for Long-Term Analysis: VWAP resets daily, making it unsuitable for analyzing long-term trends or positions held overnight. It's strictly an intraday tool.
- Lagging Indicator: VWAP is a lagging indicator, as it is an average of past price and volume. It doesn't predict future prices but confirms current market sentiment.
- Choppy Market Whipsaws: In very low volume or choppy markets, price can oscillate rapidly around VWAP, leading to frequent false signals and whipsaws.
- Lack of Direction: VWAP itself doesn't tell you the trend direction. It indicates fair value. You need to combine it with price action (e.g., price above/below VWAP) and other trend tools.
- Volume Dependency: If volume data is inaccurate or very low for an asset, VWAP's reliability can be compromised.
- Over-Reliance: Using VWAP as the sole decision-making tool is risky. It's best used as a confirmation tool alongside other technical analysis methods.
Conclusion
The Daily Volume Weighted Average Price (VWAP) is an indispensable technical indicator in Pine Script for TradingView, offering unique insights into intraday market dynamics. By providing a volume-weighted average price for the current trading session, it serves as a critical benchmark for institutional traders, a dynamic support/resistance level, and a powerful confirmation tool for short-term trends. While its daily reset makes it exclusively an intraday indicator, mastering its application for mean reversion, trend confirmation, and identifying breakouts, ideally in conjunction with VWAP bands and other volume analysis, can significantly enhance your intraday trading strategies and provide a clearer understanding of the market's true fair value.