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.
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:
The calculation of VWAP is cumulative throughout the trading day and resets at the start of each new day:
TP = (High + Low + Close) / 3TPV = TP * VolumeCumulative TPV = Sum(TPV) for the dayCumulative Volume = Sum(Volume) for the dayVWAP = Cumulative TPV / Cumulative Volume//@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))
Remember, Daily VWAP resets each session. It's a key tool for understanding price performance relative to volume for *that specific day*.
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.
//@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)
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.
//@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))
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.
//@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)
To get the most from Daily VWAP in Pine Script:
VWAP is considered the "true" average price for the day. Institutional traders often target closing positions near VWAP, making it a magnet for price.
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.
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