Indicator · Pine Script v6 · On the chart

VWAP Volatility Bands

by Focal-QuantAI· code credited to BOSWaves

An indicator on the price chart that smooths a VWAP with a T3 moving average cascade and surrounds it with ATR-scaled volatility bands.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code167
Settings12inputs
LicenceNone statedfile: MPL-2.0
Last update6 months ago11 Apr 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

167 lines of Pine Script v6 from strategies/vwap_volatility_bands_boswaves/dsV9tixIZjRr9a8RPGRI_code.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

dsV9tixIZjRr9a8RPGRI_code.pine
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © BOSWaves

//@version=6
indicator("VWAP Volatility Bands [BOSWaves]", overlay=true)

// ┌────────────────────────────── BOSWaves ─ Groups ─────────────────────────────────┐
// └──────────────────────────────────────────────────────────────────────────────────┘

color BULL = #00FF44
color BEAR = #FF0066
const string GRP_CORE   = "Core Settings"
const string GRP_VISUAL = "Visual Settings"

// ┌────────────────────────────── BOSWaves ─ Inputs ─────────────────────────────────┐
// └──────────────────────────────────────────────────────────────────────────────────┘

vwap_anchor  = input.string("Session", "VWAP Anchor", options=["Session", "Week", "Month"], group=GRP_CORE, tooltip="Defines the reset boundary for VWAP accumulation. Session resets each trading day, Week each Monday, Month each 1st.")
len          = input.int(28, "T3 Length", minval=2, group=GRP_CORE, tooltip="Lookback period for the T3 EMA cascade. Higher values produce a slower, more stable basis line.")
factor       = input.float(0.7, "T3 Factor", minval=0.0, maxval=1.0, step=0.1, group=GRP_CORE, tooltip="Higher = smoother, more lag. Lower = faster, more responsive.")
atr_len      = input.int(14, "ATR Length", minval=1, group=GRP_CORE, tooltip="Period for ATR calculation used to scale the volatility bands. Lower values make bands more reactive to recent volatility.")

show_vwap       = input.bool(true, "Show Raw VWAP", group=GRP_VISUAL, tooltip="Displays the raw cumulative VWAP as a dotted white line beneath the T3-smoothed basis.")
show_bounce     = input.bool(true, "Show Bounce Signals", group=GRP_VISUAL, tooltip="Plots bounce entry signals when price reacts from outer bands in the direction of the trend.")
bounce_cooldown = input.int(1, "Bounce Cooldown Bars", minval=0, group=GRP_VISUAL, tooltip="Minimum number of bars that must pass before another bounce signal can fire. Reduces signal noise.")
show_tp         = input.bool(true, "Show TP Signals", group=GRP_VISUAL, tooltip="Marks potential take-profit zones when price overextends beyond the outermost band against the current trend.")
paint_bars      = input.bool(true, "Color Bars", group=GRP_VISUAL, tooltip="Tints each bar based on trend direction and distance from the T3 basis. Intensity fades closer to the center.")
bull_col        = input.color(BULL, "Bullish", inline="col", group=GRP_VISUAL)
bear_col        = input.color(BEAR, "Bearish", inline="col", group=GRP_VISUAL)
base_col        = input.color(color.gray, "Basis", inline="col", group=GRP_VISUAL)

// ┌────────────────────────────── BOSWaves ─ VWAP Calculation ───────────────────────┐
// └──────────────────────────────────────────────────────────────────────────────────┘

_anchorPeriod =
     vwap_anchor == "Week"  ? timeframe.period == "1D" ? "1W" : "W" :
     vwap_anchor == "Month" ? timeframe.period == "1D" ? "1M" : "M" :
     "Session"

is_new_anchor =
     vwap_anchor == "Week"  ? weekofyear  != weekofyear[1]  or year != year[1] :
     vwap_anchor == "Month" ? month       != month[1]       or year != year[1] :
     session.isfirstbar_regular or (dayofweek != dayofweek[1] and timeframe.isintraday)

var float cum_vol    = 0.0
var float cum_tpvol  = 0.0

cum_vol   := is_new_anchor ? volume          : cum_vol   + volume
cum_tpvol := is_new_anchor ? hlc3 * volume   : cum_tpvol + hlc3 * volume

raw_vwap = cum_tpvol / cum_vol

// ┌────────────────────────────── BOSWaves ─ T3 on VWAP ─────────────────────────────┐
// └──────────────────────────────────────────────────────────────────────────────────┘

f_t3(float _src, int _len, float _factor) =>
    a  = _factor
    c1 = -a * a * a
    c2 = 3 * a * a + 3 * a * a * a
    c3 = -6 * a * a - 3 * a - 3 * a * a * a
    c4 = 1 + 3 * a + a * a * a + 3 * a * a
    e1 = ta.ema(_src, _len)
    e2 = ta.ema(e1,   _len)
    e3 = ta.ema(e2,   _len)
    e4 = ta.ema(e3,   _len)
    e5 = ta.ema(e4,   _len)
    e6 = ta.ema(e5,   _len)
    c1 * e6 + c2 * e5 + c3 * e4 + c4 * e3

t3  = f_t3(raw_vwap, len, factor)
atr = ta.atr(atr_len)

// ┌────────────────────────────── BOSWaves ─ Score Logic ────────────────────────────┐
// └──────────────────────────────────────────────────────────────────────────────────┘

var int score = 0
score := t3 > t3[1] ? 1 : t3 < t3[1] ? -1 : nz(score[1])

vwap_bull = close > raw_vwap
vwap_bear = close < raw_vwap

// ┌────────────────────────────── BOSWaves ─ Bands ──────────────────────────────────┐
// └──────────────────────────────────────────────────────────────────────────────────┘

m1 = 0.5
m2 = 1.0
m3 = 1.5
m4 = 2.2

band_u1 = t3 + atr * m1
band_u2 = t3 + atr * m2
band_u3 = t3 + atr * m3
band_u4 = t3 + atr * m4

band_l1 = t3 - atr * m1
band_l2 = t3 - atr * m2
band_l3 = t3 - atr * m3
band_l4 = t3 - atr * m4

// ┌────────────────────────────── BOSWaves ─ Plotting ───────────────────────────────┐
// └──────────────────────────────────────────────────────────────────────────────────┘

plot(show_vwap ? raw_vwap : na, "VWAP", color.new(color.white, 55), linewidth=1, style=plot.style_circles)

pt3 = plot(t3, "Basis (T3·VWAP)", score==1 ? color.new(bull_col,40) : color.new(bear_col,40), linewidth=2)

pu1 = plot(score == -1 ? band_u1 : na, "U1", color.new(bear_col, 90), style=plot.style_linebr)
pu2 = plot(score == -1 ? band_u2 : na, "U2", color.new(bear_col, 80), style=plot.style_linebr)
pu3 = plot(score == -1 ? band_u3 : na, "U3", color.new(bear_col, 55), style=plot.style_linebr)
pu4 = plot(score == -1 ? band_u4 : na, "U4", color.new(bear_col,  5), linewidth=2, style=plot.style_linebr)

pl1 = plot(score == 1 ? band_l1 : na, "L1", color.new(bull_col, 90), style=plot.style_linebr)
pl2 = plot(score == 1 ? band_l2 : na, "L2", color.new(bull_col, 80), style=plot.style_linebr)
pl3 = plot(score == 1 ? band_l3 : na, "L3", color.new(bull_col, 55), style=plot.style_linebr)
pl4 = plot(score == 1 ? band_l4 : na, "L4", color.new(bull_col,  5), linewidth=2, style=plot.style_linebr)

clamp(val, lower, upper) =>
    math.min(upper, math.max(lower, val))

bull_outer_strength = score == 1  ? clamp((t3 - close) / math.max(band_l3 - band_l4, syminfo.mintick), 0.0, 1.0) : 0.0
bear_outer_strength = score == -1 ? clamp((close - t3) / math.max(band_u4 - band_u3, syminfo.mintick), 0.0, 1.0) : 0.0

bull_outer_alpha = 85 - int(bull_outer_strength * 70)
bear_outer_alpha = 85 - int(bear_outer_strength * 70)

fill(pt3, pu1, color.new(bear_col, 97), title="Bear P1")
fill(pu1, pu2, color.new(bear_col, 92), title="Bear P2")
fill(pu2, pu3, color.new(bear_col, 82), title="Bear P3")

fill(pt3, pl1, color.new(bull_col, 97), title="Bull P1")
fill(pl1, pl2, color.new(bull_col, 92), title="Bull P2")
fill(pl2, pl3, color.new(bull_col, 82), title="Bull P3")

fill(pu3, pu4, color.new(bear_col, bear_outer_alpha), title="Bear P4")
fill(pl3, pl4, color.new(bull_col, bull_outer_alpha), title="Bull P4")

// ┌────────────────────────────── BOSWaves ─ Bar Color ──────────────────────────────┐
// └──────────────────────────────────────────────────────────────────────────────────┘

dist    = math.min(math.abs(close - t3) / (atr * m4), 1.0)
alpha   = int(dist * 70)
mid     = math.avg(open, close)

bar_col = score == 1 ? (mid < t3 ? base_col : color.new(bull_col, alpha)) : (mid > t3 ? base_col : color.new(bear_col, alpha))
barcolor(paint_bars ? bar_col : na)

// ┌────────────────────────────── BOSWaves ─ Signals ────────────────────────────────┐
// └──────────────────────────────────────────────────────────────────────────────────┘

long  = ta.crossover(t3, t3[1])
short = ta.crossunder(t3, t3[1])

plotshape(long  ? band_l4 : na, "Long",  location=location.absolute, style=shape.diamond, color=bull_col, size=size.small)
plotshape(short ? band_u4 : na, "Short", location=location.absolute, style=shape.diamond, color=bear_col, size=size.small)

tpbull = show_tp and ta.crossunder(close, band_l4) and score == -1
tpbear = show_tp and ta.crossover(close, band_u4)  and score == 1

plotchar(tpbull, "Bull TP", "⬨", location=location.belowbar, color=bear_col, size=size.small)
plotchar(tpbear, "Bear TP", "⬨", location=location.abovebar, color=bull_col, size=size.small)

// ┌────────────────────────────── BOSWaves ─ Alerts ─────────────────────────────────┐
// └──────────────────────────────────────────────────────────────────────────────────┘

alertcondition(long,             "Long Entry",  "VWAP Volatility Bands Long {{ticker}}")
alertcondition(short,            "Short Entry", "VWAP Volatility Bands Short {{ticker}}")
alertcondition(tpbull or tpbear, "TP Signal",   "VWAP Volatility Bands Take Profit {{ticker}}")

Overview

The VWAP can reset each session, week or month. Optional bounce signals mark reactions from the outer bands in the direction of the trend, with a cooldown in bars, and take profit markers appear when price stretches beyond the outer band against the trend. A raw VWAP line and bar colouring can be toggled.

Details

Published by

Focal-QuantAI on GitHub

Code credit

BOSWaves, as written in the script's header

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Volatility & bands, Volume, Mean reversion

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
VWAP AnchorstringSessionvwap_anchor
T3 Lengthint28len
T3 Factorfloat0.7factor
ATR Lengthint14atr_len
Show Raw VWAPbooltrueshow_vwap
Show Bounce Signalsbooltrueshow_bounce
Bounce Cooldown Barsint1bounce_cooldown
Show TP Signalsbooltrueshow_tp
Color Barsbooltruepaint_bars
BullishcolorBULLbull_col
BearishcolorBEARbear_col
Basiscolorcolor.graybase_col
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

9 stars

This indicator plots an anchored MIDAS support and resistance curve from launch-anchored volume-weighted price on the price chart. It adds two configurable volume-weighted standard-deviation, ATR, or hybrid bands and a topfinder or bottomfinder accelerated exh

Indicator v6 Mean reversionSupport & resistance Repaints
Updated 2 days ago · MIT GitHub repository of MIDAS 2.0 [WavesUnchained]

VWAP Trader NXi

by eddiebelaval
7 stars

VWAP Trader NXi calculates a daily session-anchored Volume Weighted Average Price along with two custom standard deviation bands on the main price chart. It plots the core VWAP, Value Area bands, outer extension zones with background shading, and the previous

Indicator v5 VolumeVolatility & bands
Updated 3 months ago · None stated GitHub repository of VWAP Trader NXi
1 stars

This indicator screens daily price charts to identify potential parabolic snapback short and washout bounce long setups. It calculates price extension using moving averages, percentage gain lookbacks, and optional Bollinger Bands filters. Long signals require

Indicator v6 Mean reversionVolume
Updated 7 months ago · None stated GitHub repository of Parabolic Snapback & Washout
1 stars

An indicator for four-hour charts that builds a rolling VWAP with standard deviation bands. A long signal appears when one bar closes below the lower band and the next closes back above it, and the reverse for shorts. Filters skip trades when ATR volatility is

Indicator v6 Mean reversionVolatility & bands
Updated 7 months ago · None stated GitHub repository of V21 VWAP Mean Reversion

Volumetric Regression Heatmap

by woodstock-tokyo
1 stars

An overlay indicator that fits a regression channel over a base period, optionally resizing the period with volatility, and fills parallel levels above and below it with a colour gradient based on traded volume. Optional mean reversion signals appear when pric

Indicator v6 VolumeMean reversion Repaints
Updated 3 months ago · None stated GitHub repository of Volumetric Regression Heatmap

The Momentum Setup is a multi-indicator visual tool designed for trend and momentum analysis directly on the price chart. It combines Relative Strength Index (RSI), Money Flow Index (MFI), Commodity Channel Index (CCI), Supertrend, and a 250-bar percentage cha

Indicator v5 Oscillators & momentumTrend
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup - Ankush Bajaj Momentum Investing Setup

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers