VWAP Stdev Bands

2479 5 284
This indicator plots VWAP with 2x Standard Deviation bands. This could potentially be used to trade a mean reversion type strategy. Only works on intraday charts.
Remove from Favorite Scripts Add to Favorite Scripts
study("VWAP Stdev Bands", overlay=true)
devNum = input(2, title="Number of stdev")
newSession = iff(change(dayofweek), 1, 0)
vwapsum = iff(newSession, hl2*volume, vwapsum[1]+hl2*volume)
volumesum = iff(newSession, volume, volumesum[1]+volume)
v2sum = iff(newSession, volume*hl2*hl2, v2sum[1]+volume*hl2*hl2)
myvwap = vwapsum/volumesum
dev = sqrt(max(v2sum/volumesum - myvwap*myvwap, 0))
plot(myvwap, title="VWAP")
plot(myvwap + devNum * dev, title="VWAP Upper")
plot(myvwap - devNum * dev, title="VWAP Lower")
The rolling standard deviation calculation for this script is incorrect and borrowed from someone else who started it (not sure who was the genesis of this mistake). For an open source version for daily, weekly, monthly, quarterly, yearly VWAP with 3 band configurations see my script:

I have cited the correct rolling weighted standard deviation calculation from a university article and adapted it to pine script.

Also shows previous VWAP values which act as future support/resistance.
great work, please let me know on what basis have you marked the red and green circles on the chart
IvanLabrie coondawg71
VWAP, a beautiful took.
I prefer the actual volume profile and manual analysis, but this is very good.
Nice work Sandro! Would you be interested in adding a couple more deviation ratios? I use 1.28 as breakout and 3.09 as a max deviation. They work very well. The typical 2.0 is very common for stocks. Larger deviations are necessary for FX. Using "IDC" data feed for FX allows us to plot Vwap bands on FX, which obviously is not the norm.
+1 Reply
EN English
EN English (UK)
EN English (IN)
DE Deutsch
FR Français
ES Español
IT Italiano
PL Polski
SV Svenska
TR Türkçe
RU Русский
PT Português
ID Bahasa Indonesia
MS Bahasa Melayu
TH ภาษาไทย
VI Tiếng Việt
JA 日本語
KO 한국어
ZH 简体中文
ZH 繁體中文
AR العربية
Home Stock Screener Forex Signal Finder Cryptocurrency Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators Website & Broker Solutions Widgets Stock Charting Library Feature Request Blog & News FAQ Help & Wiki Twitter
Profile Profile Settings Account and Billing My Support Tickets Contact Support Ideas Published Followers Following Private Messages Chat Sign Out