Docs

ITMScript

Draw VWAP bands over the whole run

Draw a volume-weighted average price with two pairs of deviation bands, accumulated from the first bar loaded.

Draw a volume-weighted average price with bands at set multiples of the spread around it.

itm
//@itmscript 2
study("VWAP bands", overlay=true)
len = input.int(50, "Window", min=2, max=1000)
inner = input.float(1, "Inner band", min=0.1, max=5, step=0.1)
outer = input.float(2, "Outer band", min=0.1, max=10, step=0.1)
vwap = ta.vwap(hlc3)
spread = ta.stdev(hlc3 - vwap, len)
plot(vwap, "VWAP", color=color.orange, width=2, style=line)
innerUp = plot(vwap + inner * spread, "Inner upper", color=color.gray, width=1, style=line)
innerLo = plot(vwap - inner * spread, "Inner lower", color=color.gray, width=1, style=line)
plot(vwap + outer * spread, "Outer upper", color=color.gray, width=1, style=stepline)
plot(vwap - outer * spread, "Outer lower", color=color.gray, width=1, style=stepline)
fill(innerUp, innerLo, color=color.new(color.orange, 92))

What you see

An orange VWAP line is drawn over the candles. Two grey lines with a light fill mark the inner band. Two grey stepped lines mark the outer band.

The VWAP accumulates over everything loaded. Write ta.vwap(hlc3, reset=session) to restart it at each session open. The time and sessions page lists the other restarts. A longer history makes the whole-run version move more slowly. The bands are the standard deviation of the distance between the typical price and the VWAP over the window.

Change these inputs

  • Window. The number of bars the spread is measured over, from 2 to 1000.
  • Inner band. The distance of the inner band, in multiples of the spread. From 0.1 to 5.
  • Outer band. The distance of the outer band, in multiples of the spread. From 0.1 to 10.