Logo
OFFLINEPIXEL
/ pinescript-strategies / pine-script-vwap-daily

$ Pine Script VWAP (Daily)

Master this indispensable intraday indicator in TradingView's Pine Script, relied upon by institutional traders for identifying fair value, optimal entry/exit points, and measuring market strength.

500+ Clients Helped
100% Satisfaction
Live Trading Ready
⚠️
Trading financial markets carries risk. All content (PineScript code, indicators, strategies) on this website is for educational purposes only. Past performance is not indicative of future results. By using any code or information from this site, you agree that you are solely responsible for your trading decisions. The author disclaims all liability for any losses incurred. To gain from experts experiences, You can always try our Invite Only Scripts
01

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.
02

Components and Calculation

The calculation of VWAP is cumulative throughout the trading day and resets at the start of each new day:

  1. Typical Price (TP): For each bar, calculate its typical price:
    TP = (High + Low + Close) / 3
  2. TP * Volume (TPV): Multiply the typical price by its volume:
    TPV = TP * Volume
  3. 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
  4. 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
  5. VWAP Formula: Divide the Cumulative TPV by the Cumulative Volume.
    VWAP = Cumulative TPV / Cumulative Volume
03

Basic Daily VWAP Implementation in Pine Script

pine-script@terminal
//@version=5
indicator("My Daily VWAP", overlay=true, timeframe="D")

// Calculate Daily VWAP using the built-in function
dailyVwap = ta.vwap(close, volume)

// Plot the VWAP line
plot(dailyVwap, title="Daily VWAP", color=color.purple, linewidth=2)

// Optional: Add Standard Deviation Bands around VWAP
stdDevLength = input.int(20, title="StdDev Lookback", 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)

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(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(upperBand1, lowerBand1, color.new(color.blue, 95))
fill(upperBand2, lowerBand1, color.new(color.navy, 98))
$ ✓ Compiled successfully
04

Intraday Focus

Intraday Focus

Remember, Daily VWAP resets each session. It's a key tool for understanding price performance relative to volume for *that specific day*.

05

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.
  • Sell Signal: Price rallies and touches or briefly penetrates above VWAP, especially if accompanied by signs of resistance.
//@version=5
strategy("VWAP Mean Reversion Strategy", overlay=true, initial_capital=10000)

dailyVwap = ta.vwap(close, volume)
plot(dailyVwap, "Daily VWAP", color=color.purple, linewidth=2)

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

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", minval=0.1, step=0.1)

lowerBandEntry = currentDailyVwap - (stdDevVwap * stdDevMultiplierEntry)
upperBandEntry = currentDailyVwap + (stdDevVwap * stdDevMultiplierEntry)
lowerBandTarget = currentDailyVwap + (stdDevVwap * stdDevMultiplierExit)
upperBandTarget = currentDailyVwap - (stdDevVwap * stdDevMultiplierExit)

plot(lowerBandEntry, "Lower Entry Band", color=color.green, style=plot.style_stepline)
plot(upperBandEntry, "Upper Entry Band", color=color.red, style=plot.style_stepline)

longCondition = close > lowerBandEntry and close[1] <= lowerBandEntry[1] and close > open
if (longCondition)
    strategy.entry("Long Reversion", strategy.long)

shortCondition = close < upperBandEntry and close[1] >= upperBandEntry[1] and close < open
if (shortCondition)
    strategy.entry("Short Reversion", strategy.short)

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.
  • Downtrend Confirmation: Price is consistently trading below VWAP, and VWAP is sloping downwards.
//@version=5
strategy("VWAP Trend Following Strategy", overlay=true)

dailyVwap = ta.vwap(close, volume)
plot(dailyVwap, "Daily VWAP", color=color.purple, linewidth=2)

vwapSlopePeriod = input.int(5, "VWAP Slope Lookback", minval=1)
isVwapUptrend = dailyVwap > dailyVwap[vwapSlopePeriod]
isVwapDowntrend = dailyVwap < dailyVwap[vwapSlopePeriod]

longCondition = ta.crossover(close, dailyVwap) and isVwapUptrend
shortCondition = ta.crossunder(close, dailyVwap) and isVwapDowntrend

if (longCondition)
    strategy.entry("Long Trend", strategy.long)

if (shortCondition)
    strategy.entry("Short Trend", strategy.short)

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.
//@version=5
strategy("VWAP Breakout Strategy", overlay=true)

dailyVwap = ta.vwap(close, volume)
plot(dailyVwap, "Daily VWAP", color=color.purple, linewidth=2)

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)

avgVolume = ta.sma(volume, 20)
isHighVolume = volume > avgVolume * minVolumeMultiplier

longBreakoutCondition = close > upperBandBreakout and close[1] <= upperBandBreakout[1] and isHighVolume
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)
06

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).
  • Combine with Volume Analysis: Since VWAP is volume-weighted, its signals are highly enhanced by confirming volume.
  • VWAP Bands: Utilize standard deviation bands around VWAP to identify overextended price levels.
  • Multi-Timeframe Context: Consider the broader trend from a higher timeframe. If the daily trend is bullish, favor long setups.
  • Institutional Levels: Be aware that large institutional players often use VWAP to evaluate their execution quality.
  • Anchor VWAP (Advanced): For multi-day analysis, consider implementing "Anchor VWAP" starting from a specific event.
07

Fair Value & Institutional Flow

Fair Value & Institutional Flow

VWAP is considered the "true" average price for the day. Institutional traders often target closing positions near VWAP, making it a magnet for price.

08

Common Daily VWAP Pitfalls

  • Not for Long-Term Analysis: VWAP resets daily, making it unsuitable for analyzing long-term trends.
  • Lagging Indicator: VWAP is a lagging indicator, confirming current market sentiment rather than predicting.
  • Choppy Market Whipsaws: In very low volume or choppy markets, price can oscillate rapidly around VWAP.
  • Lack of Direction: VWAP itself doesn't tell you the trend direction. Combine it with price action.
  • Volume Dependency: If volume data is inaccurate or very low, VWAP's reliability can be compromised.
  • Over-Reliance: Using VWAP as the sole decision-making tool is risky.
09

Conclusion

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.

Enhance Your Trading

Get a high-performance Pine Script analysis tool for actionable market insights, designed for traders on the move.

This strategy runs in live mode on TradingView, helping you identify potential opportunities.

Get Pine Script Strategy