Indicator · Pine Script v6 · On the chart

Capital41 Session VWAP v2

by damianpitt· code credited to Capital41 | MIT License

This indicator plots a session volume-weighted average price on the price chart and resets the cumulative price-volume totals when a new session begins.

View on GitHub

GitHub stars6on the repository
Pine versionv6current
Lines of code127
Settings8inputs
LicenceMIT
Last update8 weeks ago31 Aug 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

127 lines of Pine Script v6 from Capital41_Session_VWAP/Capital41_Session_VWAP_v2.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

Capital41_Session_VWAP_v2.pine
// Copyright (c) 2026 Capital41 | MIT License
// CAPITAL41 SESSION VWAP v2

// What it does:
// - Calculates an intraday VWAP that resets each session.
// - Optional standard deviation band around VWAP for context.
// - Works on intraday timeframes with volume data.
// - Status badge showing VWAP value, distance, and position.
// - Alerts on VWAP and band crosses.
//
// v2 changes:
// - ADDED: Status badge (VWAP level, % distance, above/below).
// - ADDED: Alert conditions for VWAP and 1σ band crosses, gated by
//          barstate.isconfirmed.
//
// TradingView setup:
// 1) Open TradingView -> Pine Editor.
// 2) Paste this script, Save, and Add to chart.
// 3) Use 30m or 4h on BTC or US stocks.
// 4) Choose session times and timezone to match your market.
//
// Usage guide (30m/4h):
// - VWAP acts as fair value; price above = bullish bias, below = bearish.
// - Use sweeps or MA trend for entries around VWAP.
// - For 24/7 markets, set Session to 0000-2359.



//@version=6
indicator("Capital41 Session VWAP v2", overlay = true, max_lines_count = 50)

// Inputs
useExchangeTz = input.bool(false, "Use exchange timezone")
sessTz        = input.string("America/New_York", "Session timezone",
                             options = ["America/New_York", "America/Chicago", "Etc/UTC", "Europe/London", "Asia/Tokyo"])
sessTimes     = input.session("0930-1600", "Session times")

showVwap      = input.bool(true, "Show VWAP")
showBands     = input.bool(false, "Show 1σ bands")
bandMult      = input.float(1.0, "Band multiplier", minval = 0.1, maxval = 3.0)
showOnlySession = input.bool(true, "Plot only during session")
showBadge     = input.bool(true, "Show status badge")

colorVwap = color.new(color.blue, 0)
colorBand = color.new(color.blue, 70)
colorBull = color.new(color.lime, 0)
colorBear = color.new(color.red, 0)


// Session detection
inSession = useExchangeTz ? not na(time(timeframe.period, sessTimes)) : not na(time(timeframe.period, sessTimes, sessTz))
newSession = inSession and not inSession[1]


// Session VWAP (manual)
var float cumPV = 0.0
var float cumV  = 0.0
var float cumP2V = 0.0

if newSession
    cumPV := 0.0
    cumV := 0.0
    cumP2V := 0.0

if inSession
    tp = hlc3
    cumPV += tp * volume
    cumV  += volume
    cumP2V += tp * tp * volume

vwap = cumV > 0 ? cumPV / cumV : na
variance = cumV > 0 ? (cumP2V / cumV) - (vwap * vwap) : na
stdev = variance > 0 ? math.sqrt(variance) : 0.0

// Raw band levels, kept independent of display toggles so alerts still work
// when the bands are hidden
vwapUpper = vwap + stdev * bandMult
vwapLower = vwap - stdev * bandMult

visible  = not showOnlySession or inSession
vwapPlot = showVwap and visible ? vwap : na
upper = showBands and visible ? vwapUpper : na
lower = showBands and visible ? vwapLower : na

plot(vwapPlot, title = "Session VWAP", color = colorVwap, linewidth = 2)
plot(upper, title = "VWAP Upper", color = colorBand, linewidth = 1)
plot(lower, title = "VWAP Lower", color = colorBand, linewidth = 1)


// Status badge
var table status = table.new(position.top_right, 3, 1, border_width = 1)
if barstate.islast
    if showBadge and not na(vwap)
        dist    = vwap != 0 ? (close - vwap) / vwap * 100 : 0
        above   = close > vwap
        posText = above ? " ABOVE " : " BELOW "
        posBg   = above ? color.new(colorBull, 65) : color.new(colorBear, 65)

        table.cell(status, 0, 0, " VWAP " + str.tostring(vwap, format.mintick) + " ",
                   bgcolor = color.new(colorVwap, 70), text_color = color.white, text_size = size.tiny)
        table.cell(status, 1, 0, " " + str.tostring(dist, "#.##") + "% ",
                   bgcolor = above ? color.new(colorBull, 70) : color.new(colorBear, 70),
                   text_color = color.white, text_size = size.tiny)
        table.cell(status, 2, 0, posText, bgcolor = posBg,
                   text_color = color.white, text_size = size.tiny)
    else
        for i = 0 to 2
            table.cell(status, i, 0, "", bgcolor = color.new(color.black, 100), text_color = color.new(color.black, 100))


// Alerts (crosses hoisted so ta.* runs every bar, then confirmed on bar close)
vwapCrossUp   = ta.crossover(close, vwap)
vwapCrossDown = ta.crossunder(close, vwap)
upperCross    = ta.crossover(close, vwapUpper)
lowerCross    = ta.crossunder(close, vwapLower)

alertcondition(vwapCrossUp and barstate.isconfirmed, title = "VWAP Cross Up",
               message = "Session VWAP: price closed above VWAP on {{ticker}} ({{interval}})")

alertcondition(vwapCrossDown and barstate.isconfirmed, title = "VWAP Cross Down",
               message = "Session VWAP: price closed below VWAP on {{ticker}} ({{interval}})")

alertcondition(upperCross and barstate.isconfirmed, title = "VWAP Upper Band Cross",
               message = "Session VWAP: price closed above the upper band on {{ticker}} ({{interval}})")

alertcondition(lowerCross and barstate.isconfirmed, title = "VWAP Lower Band Cross",
               message = "Session VWAP: price closed below the lower band on {{ticker}} ({{interval}})")

Overview

Capital41 Session VWAP v2 uses typical price and volume, and can draw optional standard-deviation bands around the VWAP. A corner badge shows the current VWAP, percent distance from close, and whether price is above or below. Inputs set the timezone, session hours, band multiplier, and whether plots appear only inside the session. Confirmed alerts fire when price crosses the VWAP or the bands. It needs volume and is aimed at 30-minute and 4-hour charts on Bitcoin and US stocks.

Details

Published by

damianpitt on GitHub

Code credit

Capital41 | MIT License, as written in the script's header

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Sessions & time, Volume, Volatility & bands

Markets

Crypto, Stocks

Timeframes

M15-H1, H4 and above

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.

Topics

cryptoindicatorsmarket-structureorder-blockspinescriptsmart-moneytechnical-analysistechnical-analysis-indicatorstradingtradingview

Settings

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

SettingTypeDefaultVariable
Use exchange timezoneboolfalseuseExchangeTz
Session timezonestringAmerica/New_YorksessTz
Session timessession0930-1600sessTimes
Show VWAPbooltrueshowVwap
Show 1σ bandsboolfalseshowBands
Band multiplierfloat1.0bandMult
Plot only during sessionbooltrueshowOnlySession
Show status badgebooltrueshowBadge
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

LoD Intraday Entry

by ChartsLector
41 stars

This overlay indicator marks the current day's low and a suggested entry zone a fraction of daily ATR below that low. It compares daily volume with a volume moving average, plots daily SMA and EMA distance, and draws an optional ATR-width price cloud. Labels c

Indicator v6 Support & resistanceVolatility & bands
Updated 2 days ago · None stated GitHub repository of LoD Intraday Entry
9 stars

Peak Trading Activity Graphs displays historical market activity across cyclical timeframes directly on the main chart using an on-screen dashboard table. It evaluates volume or volatility across selected periods, including hours of the day, days of the week,

Indicator v6 VolumeVolatility & bands
Updated 4 months ago · MIT GitHub repository of Peak Trading Activity Graphs [LuxAlgo]

VWAP Bands [trugurpala]

by trugurpala
4 stars

This indicator plots a volume-weighted average price that restarts at the beginning of each daily session, using typical price and cumulative volume. It draws the VWAP line on the price chart and optional standard-deviation bands at two user-set multipliers. B

Indicator v6 VolumeVolatility & bands
Updated 2 months ago · MIT GitHub repository of VWAP Bands [trugurpala]

This indicator plots a Supertrend-based trend-following setup in a separate pane and skips conditions it treats as a sideways market. A volatility range is built from an ATR value, with RMA, SMA, EMA, or WMA smoothing, or from a fixed point distance. Optional

Indicator v5 TrendVolatility & bands
Updated 1 year ago · MPL-2.0 GitHub repository of Trend Following Setup - Sideways Market Skipper

VP

by dearvn
257 stars

This indicator calculates and plots a session-based volume profile directly on the price chart. It maps volume distribution across price levels, highlighting key structural reference points including the Point of Control, Value Area High, and Value Area Low. C

Indicator v5 VolumeSupport & resistance
Updated 6 weeks ago · None stated GitHub repository of VP
219 stars

An educational Pine Script v4 indicator demonstrating how to plot volume histograms on the main price chart using unscaled axes. The code includes examples and commented templates for creating vertical line markers at specific dates or time zones, such as mark

Indicator v4 Sessions & timeVolume
Updated 5 years ago · None stated GitHub repository of 教學-畫垂直線1

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