Anchored VWAP guide
Anchored VWAP on TradingView: choose a start, then calculate
Anchored VWAP is a volume-weighted average that starts at a bar or event you choose instead of resetting only at the regular session boundary.
Direct answer
Anchored VWAP equals cumulative price multiplied by volume divided by cumulative volume, with both totals beginning at a selected anchor. Use it to describe volume-weighted price since a reproducible event or bar. Being above or below the line describes location relative to that average; it does not predict the next move.
What to set before testing
Formula
Cumulative price-volume / cumulative volume
Start
A user-selected bar, date, or event
Common use
Measure value since a defined market event
Main risk
Moving the anchor after seeing the result
Anchored VWAP and session VWAP are different questions
Both calculations weight price by volume. The start rule determines which bars are included and therefore which market question the line can answer.
| Decision | Session VWAP | Anchored VWAP |
|---|---|---|
| Starting point | A defined session or period boundary | A bar, date, swing, gap, or event chosen by the user |
| Question answered | Where is volume-weighted value for this session? | Where is volume-weighted value since this event? |
| Typical scope | Intraday analysis with a regular reset | Intraday or higher-timeframe analysis from a stated anchor |
| Failure mode | Comparing lines built from different session definitions | Choosing an anchor because it makes the past move look convincing |
A test workflow you can audit
- 1
Write the market question
Decide whether the line should describe today's session, price since an earnings bar, a dated gap, or another event before opening the chart.
- 2
Record the anchor
Save the symbol, timezone, date, timestamp, chart timeframe, and whether extended-hours volume is included.
- 3
Read the calculation
Compare price with the line and note volume at each interaction. Label a cross, touch, or rejection as an observation until a rule defines it.
- 4
Test the rule separately
Keep the anchor rule fixed, include costs and slippage, and review a later sample before treating the result as useful evidence.
Checks to make on your chart
These checks keep the rule separate from the story told after a move has already happened.
Lock the anchor timestamp before reviewing the candles that follow it.
Record the session and extended-hours policy because different volume inputs can produce different lines.
Treat support or resistance around the line as an observation to test, not as a guaranteed reaction.
Turn an anchored VWAP idea into inspectable Pine Script
Pineify's Pine Script AI Coding Agent can turn a written anchor, source, plot, and test rule into editable TradingView code. The output still needs review and testing on the chart.
Create a Pine Script v6 indicator for TradingView that calculates Anchored VWAP from a user-selected timestamp using HLC3 and volume. Start both cumulative totals at the first bar on or after the timestamp, plot the line, show the anchor time in the settings, and do not add buy or sell claims. Use only loaded chart-session bars. Treat zero volume as zero weight, stop on missing volume, and reject an anchor older than loaded history. Add optional volume-weighted population deviation bands and explain live-bar updates.Turn the rule into inspectable Pine ScriptAdd the drawing tool or use a timestamp input
In TradingView, select Anchored VWAP from the drawing tools on the left and click the starting bar. Open its settings to adjust its appearance. A Pine indicator is separate from this drawing: input.time supplies a timestamp for your own calculation.
The example uses the first bar whose opening time is on or after the input. On a five-minute chart, a 09:31 anchor starts at 09:35 when that bar exists. A date inside a market closure starts at the next available bar. A future anchor produces no line until a qualifying bar arrives.
The default timestamp includes UTC explicitly. The input displays in the chart timezone, but its UNIX timestamp represents the same instant. Save the exact timestamp, chart timeframe, symbol, and session when comparing calculations.
Missing volume and incomplete history
Zero-volume bars have zero weight. If cumulative volume is still zero, the average is undefined and the example plots nothing. Missing volume is not zero: the example stops with an error rather than silently producing an average from an incomplete sample.
An anchor older than the first loaded bar also stops the example. Load enough history or choose a later anchor. The script cannot reconstruct absent bars or extended-hours data excluded by chart settings. Tick volume and exchange trade volume describe different quantities; check the feed before comparing symbols.
Recalculation and reset behavior
Changing the time input reruns the script over available history with new totals. It does not preserve the old anchor. This example has one fixed start and no daily reset; session VWAP instead starts a new accumulation at each defined session boundary.
The open bar changes with incoming price and volume. Ordinary var state rolls back before each live-bar update, so the current bar is recalculated from the previous committed state. Use closed-bar conditions for any later signal rule. Reloading revised data, changing timeframe, or changing chart sessions can change the line.
What the deviation bands measure
The example defines sigma as the volume-weighted population standard deviation of HLC3 since the same anchor: sqrt(sum(volume * (HLC3 - current AVWAP)^2) / sum(volume)). It updates this quantity with a weighted running mean and squared-deviation accumulator.
Bands equal AVWAP plus or minus the chosen multiple of sigma. This is an explicit bar-price dispersion measure, not a confidence interval or a probability that price will stay inside. It is not a rolling ta.stdev window or a standard deviation of the plotted VWAP series. Compare formulas before expecting another indicator or drawing to match.
Anchored VWAP definition and formula
Anchored VWAP is the running average of a price source weighted by volume from a chosen starting point. With HLC3 as the source, each bar contributes (high + low + close) / 3 multiplied by that bar's volume.
The running price-volume total is divided by the running volume total. A high-volume bar therefore moves the line more than a low-volume bar at the same price distance. The calculation is descriptive: it summarizes included trades rather than forecasting the next candle.
How to choose an anchor on TradingView
TradingView's Anchored VWAP drawing tool lets the user select the starting point on a chart. For a repeatable test, translate that visual choice into a rule another person could reproduce from a timestamp or event description.
- Use the first bar after a dated earnings release, gap, or session open when that event is the question.
- Record the chart timezone and whether the anchor refers to regular or extended hours.
- A pivot needing right-side bars is known only after those bars close. A strategy cannot trade from the earlier pivot bar using that later confirmation.
- Do not move the anchor after reviewing the later price path.
How to read an anchored VWAP line
Price above the line is above the volume-weighted average since the anchor; price below it is below that average. A touch, cross, or rejection can become a rule, but the chart observation alone is not a signal or a return estimate.
The average does not reveal where trades cluster, which participants traded, or institutional intentions. Test any support or resistance rule across separate samples with the same timeframe, session, and cost assumptions.
- Describe the event and timestamp before interpreting the level.
- Separate a price-location observation from an entry, exit, or risk rule.
- Compare the line with volume and other context without claiming that one indicator confirms a trade.
Build and test an anchored VWAP rule
A Pine Script implementation needs an explicit anchor condition, price source, volume policy, and plot behavior. If the rule is used in a strategy, also define closed-bar timing, entry and exit assumptions, commission, slippage, and a holdout period.
The VWAP Calculator can check the arithmetic from OHLCV rows and a selected starting bar. The Pine Script AI Coding Agent can draft the same definition as editable code for TradingView testing.
- Keep the anchor fixed across the design and validation samples.
- Check whether missing, zero, or extended-hours volume changes the calculation.
- Review drawdown, losing trades, and costs instead of relying on one headline metric.
Pine Script v6: a fixed timestamp and weighted bands
Paste this complete indicator into Pine Editor, add it to a standard candlestick chart, and select an anchor inside the loaded history. It uses HLC3 and all bars supplied by the chart session. It does not reset each day or use a later pivot to choose an earlier anchor.
//@version=6
indicator("Timestamp anchored VWAP", overlay = true)
int anchorTime = input.time(timestamp("01 Jan 2026 00:00 +0000"), "Anchor time", confirm = true)
bool showBands = input.bool(true, "Show weighted deviation bands")
float multiplier = input.float(1.0, "Deviation multiplier", minval = 0.0, step = 0.25)
if barstate.isfirst and time > anchorTime
runtime.error("Anchor precedes loaded history. Load more bars or choose a later anchor.")
bool included = time >= anchorTime
var float sumVolume = 0.0
var float meanPrice = 0.0
var float weightedM2 = 0.0
if included
if na(volume) or volume < 0
runtime.error("Missing or invalid volume after the anchor.")
if volume > 0
if na(hlc3)
runtime.error("Missing HLC3 after the anchor.")
float nextVolume = sumVolume + volume
float delta = hlc3 - meanPrice
float nextMean = meanPrice + volume / nextVolume * delta
weightedM2 += volume * delta * (hlc3 - nextMean)
meanPrice := nextMean
sumVolume := nextVolume
bool hasValue = included and sumVolume > 0
float avwap = hasValue ? meanPrice : na
float sigma = hasValue ? math.sqrt(math.max(weightedM2 / sumVolume, 0.0)) : na
plot(avwap, "Anchored VWAP", color = color.blue, linewidth = 2, style = plot.style_linebr)
upper = plot(showBands ? avwap + multiplier * sigma : na, "Upper band", color = color.gray, style = plot.style_linebr)
lower = plot(showBands ? avwap - multiplier * sigma : na, "Lower band", color = color.gray, style = plot.style_linebr)
fill(upper, lower, color = color.new(color.blue, 92))Checks to run on your chart
- Select an anchor between two bar opens: the line should begin at the next open with positive cumulative volume. A future timestamp should leave the plots empty.
- With positive volume on the first included bar, AVWAP should equal that bar's HLC3 and both bands should meet the line. A zero-volume bar should leave existing totals unchanged.
- For a synthetic two-bar check, prices 100 and 102 with volumes 100 and 300 give AVWAP 101.5 and sigma about 0.8660. These are arithmetic fixtures, not trading results.
- Change the anchor and reload. Compare closed bars using the same source, timeframe, session, and data. Missing volume or an anchor before loaded history should produce an explicit error.
The syntax check does not establish chart behavior or performance. These chart checks are a reproducible procedure; no live trading or backtest result is claimed.
Continue the VWAP research
VWAP vs Anchored VWAP
Compare the two starting rules and keep the same assumptions when testing them.
VWAP indicator for TradingView
Review the indicator formula, inputs, bands, and Pine Script implementation.
VWAP calculator
Calculate a volume-weighted average from price and volume rows.
VWAP trading strategy
Study rule-based VWAP entries and exits before testing a setup.
VWAP strategy optimizer
Compare VWAP parameters without hiding costs or holdout results.
TradingView indicator guides
Browse indicator calculations, inputs, and Pine Script examples.
TradingView guides
Find related Pine Script, chart setup, and testing guides.
Anchored VWAP in Pine Script with deviation bands
Read a separate Pine Script example for anchored VWAP and deviation bands.
Visual Pine Script Editor
Build the indicator logic visually, then inspect the generated Pine Script before testing it in TradingView.
Sources
- Volume Weighted Average Price (VWAP)
TradingView Help Center. Documents the VWAP formula, anchor periods, source input, bands, and timeframe behavior. Checked October 16, 2026.
- Anchored VWAP drawing tool
TradingView Help Center. Explains that Anchored VWAP starts at a point selected by the user on the chart. Checked October 16, 2026.
- Pine Script time inputs
TradingView documentation. Documents input.time and re-execution after input changes. Checked October 16, 2026.
- Pine Script time and timezones
TradingView documentation. Explains UNIX timestamps, bar opening times, and chart timezone display. Checked October 16, 2026.
- Pine Script execution model
TradingView documentation. Explains historical execution, realtime updates, rollback, and persistent variables. Checked October 16, 2026.
- Repainting and pivot confirmation
TradingView documentation. Explains changing realtime values, past plotting, and dataset revisions. Checked October 16, 2026.
Frequently asked questions
This page is an educational information tool, not investment advice or a recommendation to trade. Examples are test definitions, not live signals, historical results, or promises of returns. VWAP is based on past price and volume, and actual fills can differ from chart prices. Check current market data, costs, product rules, and your own risk limits before trading.
Tools for the next test
VWAP vs Anchored VWAP
Compare session VWAP and Anchored VWAP by starting point, reset, timeframe, and test use case.
What Is VWAP?
Learn the VWAP formula, session reset, chart meaning, and calculation limits with a small worked example.
VWAP Calculator
Calculate VWAP (Volume Weighted Average Price) from OHLC and volume data, with an optional start date for an anchored calculation.
VWAP Reclaim Strategy
Define a closed-bar VWAP reclaim, entry, invalidation, session window, and cost assumptions before testing.
Put the VWAP rule in writing
Pineify turns a plain-language setup into Pine Script you can read, edit, and test. The script does not predict the next price.
Build a VWAP test rule