Code Library / VWAP

Pine Script VWAP Bands

VWAP with standard deviation bands for intraday levels.

Language: Pine Script · Category: VWAP · Tags: VWAP, standard deviation, bands, Pine Script, intraday

Source code

//@version=5
indicator("VWAP Bands",overlay=true)
v=ta.vwap(hlc3)
svol=ta.cum(hlc3*volume); sv=ta.cum(volume)
s2v=ta.cum(hlc3*hlc3*volume)
sd=math.sqrt(math.max(s2v/sv-math.pow(svol/sv,2),0))
plot(v,"VWAP",color.blue,2)
plot(v+sd,"+1SD",color.new(color.blue,60))
plot(v-sd,"-1SD",color.new(color.blue,60))
plot(v+sd*2,"+2SD",color.new(color.orange,60))
plot(v-sd*2,"-2SD",color.new(color.orange,60))

How to use this snippet

This is a building block, not a finished trading system. Paste it into your own Pine Script project, compile it, and test it on a demo account with your broker's real spreads before relying on it. You can convert it to MQL4 or MQL5 with the Pine Script converter.

Related snippets