Indicator TutorialPine Script 6

TradingView VWAP: sessions, bands and settings

Add Volume Weighted Average Price from Indicators, then set the anchor period and price source. Your chart session determines which bars contribute volume.

VWAP divides cumulative price times volume by cumulative volume from a reset point. Session VWAP resets each trading day; an anchored VWAP starts at a chosen bar; a rolling VWAP drops observations as its window moves. This guide explains those differences and includes a Pine v6 example for intraday charts with daily, weekly or monthly resets.

Add VWAP and choose the calculation window

  1. Open Indicators on a TradingView chart, search for VWAP, and select the built-in Volume Weighted Average Price.
  2. Open its Settings. Choose an Anchor Period, check Source, and keep Offset at zero while comparing values.
  3. Check the chart session and the indicator calculation timeframe before comparing it with another script.

TradingView's VWAP settings reference documents Session, Week and longer reset periods, hlc3 as the default source, and standard-deviation or percentage band modes. A multiplier of 1 in percentage mode means 1%, not one standard deviation.

  • Session VWAP: accumulates within a trading day. Its start depends on the symbol and session data, not a universal cash-market opening time.
  • Weekly or monthly VWAP: accumulates across multiple trading days until the next period boundary.
  • Anchored VWAP: begins at a selected point. TradingView's Anchored VWAP drawing tool is selected from the left drawing toolbar; click a chart point to set its start. See our anchored VWAP guide.
  • Rolling VWAP: keeps only observations inside a moving time or bar window. A fixed-bar volume-weighted average is commonly called VWMA. This is different from periodically resetting a cumulative total.

Browse related studies in the TradingView indicators directory. This tutorial and its example are readable without a Pineify subscription; product access is separate.

Why Traders Use This Indicator

  • Compare the current price with a volume-weighted reference over an explicit window.
  • Define repeatable price-crossing conditions for alerts or later strategy testing.
  • Compare references from different anchors while keeping the same source and data feed.
ParameterDefaultDescription
Sourcehlc3The bar price used in the calculation: (high + low + close) / 3. Close, hl2 or another source produces a different series.
Anchor periodSession in this exampleControls when accumulation restarts. Choose a period containing multiple chart bars. This is not a moving-average length.
Chart sessionSymbol and chart dependentRegular and extended sessions can contain different prices and volumes. Check the selected session before comparing VWAP values.
Band multiplier1.0 in this exampleScales the native ta.vwap standard-deviation bands. It does not specify a reversal probability or a price target.
Calculation timeframeChart in this exampleChanges the bars feeding the calculation. A VWAP made from daily hlc3 values need not equal one made from intraday hlc3 values.

Source, volume and reset boundaries

VWAP = sum(source × volume) / sum(volume), using bars from the current anchor through the current bar. If total volume is zero, that ratio is undefined. Bar-source VWAP is an aggregation of chart data; it does not reconstruct the price of every individual trade.

A reproducible arithmetic example: source prices of 100 and 110 with volumes of 300 and 100 give (100 × 300 + 110 × 100) / 400 = 102.5. Reset before the second bar and the result is 110. A rolling two-bar window would instead remove the oldest observation when a third bar arrives.

The code below calls ta.vwap(source, reset, multiplier) for the baseline and bands. It avoids a common custom-band error: summing deviations from a different running mean on each bar does not calculate variance around the final period mean. Bands are descriptive; no normal distribution or fixed percentage of future observations is assumed.

Session and timezone: changing from regular to extended data changes the input bars. Futures can have overnight sessions, and the exchange's named regular session can differ from a cash-equity schedule. A reset detected with timeframe.change("1D") is a daily timeframe boundary for the symbol, not a hard-coded 09:30 New York filter. Changing the chart display timezone does not impose a new exchange session. See the Pine session documentation.

Volume availability: the feed may supply trade volume, tick volume, or no usable volume. Tick volume counts price updates rather than shares or contracts. Pine does not manufacture exchange volume when it is missing. See TradingView's volume-data explanation. The example stops on missing volume or a dataset with no positive cumulative volume.

Signal Interpretation

A close above VWAP says that the closing price exceeds this window's volume-weighted reference. It does not identify who traded or prove that buyers control the next move. Repeated crosses can occur when price moves around the average.

A band touch describes distance under that band's calculation. It is not proof of exhaustion, a guaranteed return to VWAP, or a measured win rate. The example provides confirmed closing-price cross alerts and suppresses them on reset bars, where the reference itself changes abruptly. This is educational material, not investment advice.

Combining with Other Indicators

Compare Session and Weekly VWAP only after matching source, feed, session and calculation timeframe. Their agreement is a condition you can test, not independent proof of an edge.

A price or trend filter can be added to a VWAP cross with the Pine Script AI Coding Agent. Specify the reset rule and alert timing in the request, then inspect the generated code and test it on the target chart. For event-based references, use the anchored VWAP tutorial.

Writing Pine Script Manually

Challenges of Manual Coding

Separating a reset condition from a session filter: a daily reset alone does not exclude extended-hours bars.

Handling unavailable volume without silently substituting an unweighted average.

Distinguishing a price cross from a reference jump on the reset bar.

Pine Script 6
//@version=6
indicator("VWAP: Period, Bands and Confirmed Crosses", overlay=true)

source = input.source(hlc3, "Source")
anchorPeriod = input.string("Session", "Anchor Period", options=["Session", "Week", "Month"])
bandMultiplier = input.float(1.0, "Standard Deviation Multiplier", minval=0.1, step=0.1)
showBands = input.bool(true, "Show Bands")

if not timeframe.isintraday
    runtime.error("Use this example on an intraday chart.")
if na(volume)
    runtime.error("This example requires volume on every chart bar.")

var float datasetVolume = 0.0
datasetVolume += nz(volume)
if barstate.islast and datasetVolume == 0.0
    runtime.error("No positive volume is available for this dataset.")

anchorTimeframe = switch anchorPeriod
    "Week" => "1W"
    "Month" => "1M"
    => "1D"

// The first loaded period may be partial. Later periods start at their boundary.
periodChanged = timeframe.change(anchorTimeframe)
reset = barstate.isfirst or periodChanged
[vwapLine, upperBand, lowerBand] = ta.vwap(source, reset, bandMultiplier)

plot(vwapLine, "VWAP", color=color.blue, linewidth=2)
upperPlot = plot(showBands ? upperBand : na, "Upper Band", color=color.teal)
lowerPlot = plot(showBands ? lowerBand : na, "Lower Band", color=color.teal)
fill(upperPlot, lowerPlot, color=color.new(color.teal, 92), title="Band Fill")

crossUp = ta.crossover(close, vwapLine)
crossDown = ta.crossunder(close, vwapLine)
validCrossBar = not reset and not na(vwapLine) and not na(vwapLine[1])
confirmedUp = barstate.isconfirmed and validCrossBar and crossUp
confirmedDown = barstate.isconfirmed and validCrossBar and crossDown

alertcondition(confirmedUp, "Close Crossed Above VWAP", "Close crossed above VWAP on a confirmed bar.")
alertcondition(confirmedDown, "Close Crossed Below VWAP", "Close crossed below VWAP on a confirmed bar.")

Maintenance Note: This example uses chart data and daily, weekly or monthly boundaries. It does not implement an RTH-only filter, an arbitrary event anchor, or rolling VWAP. The first loaded period may be incomplete; compare a later complete period. Open-bar values still change with incoming data. Alerts require bar confirmation, must be created in TradingView, and should be recreated after changing script inputs.

Build with Pineify Visual Editor

Pineify lets you configure supported indicators and export Pine Script. Available settings and plan requirements vary by indicator. Compare the generated rules with the example before using its signals.

FeatureManual Pine ScriptPineify Visual Editor
Source and reset periodSet a source input and pass a reset condition to ta.vwap.The VWAP block exposes Source and Anchor Period inputs.
Band outputRequest the three-value ta.vwap result and plot its bands.The VWAP block exposes a Standard Deviation Multiplier and VWAP, Upper and Lower outputs.
Custom conditionsWrite and inspect conditions for crossings and bar confirmation.Use VWAP outputs in visual conditions or describe a custom rule to the AI Coding Agent, then review the result.

Configure the existing VWAP block through source, anchor timeframe and band multiplier inputs.

Style the baseline, upper and lower plots and the band fill.

Inspect exported code and compare it with the same TradingView data before relying on a signal.

Step-by-Step Tutorial

1

Create an overlay indicator

Open the Pineify Visual Editor and create an indicator that plots on the price chart.

2

Add Volume Weighted Average Price

Set Source, Anchor Period and Standard Deviation Multiplier in the VWAP block.

3

Configure outputs and conditions

Style the VWAP, Upper and Lower outputs. If you add a cross condition, review its reset-bar and bar-close behavior.

4

Export and compare

Add the exported Pine Script to TradingView. Match the built-in VWAP settings and inspect a complete period before creating alerts.

Trading Strategies & Pro Tips

Cross-rule test

Record confirmed closes crossing VWAP and define entry, exit, costs and risk rules before testing a strategy. A plotted crossing alone has no measured trading performance.

Pro Tip: Inspect reset bars separately: a jump in the reference can look like a price crossing.

Band-return hypothesis

If testing returns from an outer band toward VWAP, specify the band mode, anchor, maximum holding time and loss rule. Do not infer a reversal probability from the band multiplier.

Pro Tip: Keep a separate evaluation period and report transaction costs and drawdowns.

Session comparison

Compare regular and extended chart sessions on the same symbol and dates. Record which bars each calculation includes before interpreting the difference.

Common Mistakes to Avoid

  • Assuming Session always means the US equity cash session, or that changing the chart display timezone changes the reset rule.
  • Treating a daily reset on a daily chart as an intraday average: it has only one chart observation per reset.
  • Comparing scripts with different sources, volume feeds, calculation timeframes or band modes.
  • Treating tick volume as traded shares, or expecting a valid VWAP when volume is unavailable.
  • Using the first partially loaded period as evidence that two full-period calculations disagree.

Frequently Asked Questions

Open VWAP Settings and change Anchor Period. Session, Week and Month are reset schedules, not lookback lengths. Choose an anchor that contains multiple chart bars. Check the separate calculation timeframe as well.

They use the same cumulative weighting idea but different start rules. Session VWAP restarts each trading day. The Anchored VWAP drawing starts from the chart point you select and accumulates forward. A rolling VWAP instead removes old observations as its window advances.

A weekly or monthly anchor can accumulate multiple daily bars. A daily reset on a daily chart has only one source observation per period and is not an intraday VWAP. The example here intentionally accepts only intraday charts; daily-bar and intraday calculations need not match.

Choose the data window your rule is intended to measure, then keep it consistent. Including extended hours changes the observations and their volume weights. Session definitions vary by symbol and exchange; there is no universal session choice that establishes better performance.

Check volume availability, its type, the source, chart timeframe, session and anchor boundary. Some feeds provide tick volume or no volume. The example rejects missing volume rather than substituting a price-only average.

No. A descriptive band is not a forecast or a measured reversal probability. Price observations need not follow a normal distribution, and a trend can continue outside a band. This page provides no backtest or performance estimate.

No. VWAP and its bands update while the current bar receives price and volume data. Bar confirmation limits the example alert conditions to the close; it does not freeze the plotted open-bar values or eliminate feed revisions.

Build a VWAP indicator with explicit rules

  • Choose a source, anchor timeframe and band multiplier in the Visual Editor.
  • Add conditions using the VWAP, Upper and Lower outputs.
  • Review the generated Pine Script and validate its chart behavior.

Disclaimer: Trading involves significant risk. The indicators, code, and strategies provided are for educational purposes only and do not constitute financial advice. Past performance is not indicative of future results.