Indicators··5 min read

Anchored VWAP

0 references, link-verifiedEditor of record: Shane CantyStandards review editorial standard · audit log

VWAP (Volume-Weighted Average Price) calculation typically begins from the start of the day or a fixed historical point. An anchored VWAP allows the trader to select a specific bar in the past and calculate VWAP forward from that point, creating a dynamic reference that reflects price-volume behavior over a custom lookback window. This is useful for traders who wish to assess how price has moved relative to average value since a particular event, support level, or structural break.

//@version=6
indicator("Anchored VWAP", overlay=true)

// Input parameters
anchorBarsBack = input.int(50, title="Anchor Point (bars back)", minval=0,
                            tooltip="Number of bars in the past to anchor VWAP calculation")
vwapColor = input(color.blue, title="VWAP Color")
lineWidth = input.int(2, title="Line Width", minval=1, maxval=5)

// Calculate number of bars from anchor to current bar (inclusive)
barsFromAnchor = bar_index - math.max(0, bar_index - anchorBarsBack)

// Calculate anchored VWAP
// VWAP = sum(close * volume) from anchor to current / sum(volume) from anchor to current
cumVolumePrice = ta.sum(close * volume, barsFromAnchor + 1)
cumVolume = ta.sum(volume, barsFromAnchor + 1)
anchoredVWAP = cumVolumePrice / cumVolume

// Plot the anchored VWAP
plot(anchoredVWAP, title="Anchored VWAP", color=vwapColor, linewidth=lineWidth)

How the code works

The anchor point is set by the user as a number of bars in the past. The expression bar_index, math.max(0, bar_index, anchorBarsBack) calculates how many bars exist from the anchor to the current bar, clamping to zero if the anchor would reach before bar zero. This count, plus one (to include both endpoints), becomes the length parameter for ta.sum(). The indicator then sums the product of close price and volume over that length, and divides by the sum of volume over the same period. Since both summations use the same length and are recalculated each bar, the anchored VWAP grows as new bars arrive, always including exactly the bars from anchor to present.

Reading it on a chart

Plot the indicator on a chart with price bars. Adjust the "Anchor Point" input to move the anchor backward or forward in time. The VWAP line appears from the anchor onward, ascending or descending based on the weighted average of closes above or below where price was at the anchor. When price trades above the anchored VWAP, it indicates the average price (weighted by volume) since the anchor is below current price; below the line suggests price is below the average. Traders often use anchored VWAP as a dynamic support or resistance level to gauge whether price is performing stronger or weaker than its volume-adjusted average over a chosen period.

Limitations

Anchored VWAP is sensitive to the choice of anchor: moving the anchor point significantly alters the calculation and may create false signals if the anchor is placed at a volatile or atypical bar. The indicator offers no prediction of future price movement; it is descriptive only. Volume anomalies (e.g., flash crashes, stock splits, corporate actions not reflected in the data) distort the weighting and can produce unintuitive VWAP levels. In low-volume markets or thin instruments, large single trades can disproportionately drag VWAP, limiting its reliability as a median price reference. The indicator does not account for intrabar volume distribution, only close and total bar volume, meaning it obscures price-volume interaction within each candle. Anchored VWAP also does not adjust for time; if the anchor is moved, the entire line recalculates from a different starting point, which can be visually confusing when back-testing multiple anchor points on the same chart.

Key definitions

VWAP (Volume-Weighted Average Price): The ratio of cumulative volume-weighted price to cumulative volume, expressing the average price at which an asset traded over a period, weighted by the volume at each price level.

Anchor point: A user-selected bar from which a calculation or analysis begins; in this case, the bar index from which VWAP summation starts.

Bar index: The sequential numerical position of a candle or bar on a chart, where the oldest bar on the visible chart has a lower index and the newest has a higher one.

Close price: The final traded price of an asset during a bar's time interval.

Volume: The total quantity of an asset traded during a bar's time interval, typically expressed in shares, contracts, or notional value.

Cumulative sum: A running total that adds each new value to the prior sum, creating a monotonically increasing (or decreasing) sequence.

References


Educational research on historical data only. Not investment advice, not a signal, and never a performance promise. Past results do not predict future performance. Every reference is link-verified before publication and every paper is re-audited weekly against the library's editorial standard.

Last reviewed by the PropLedger research pipeline: 2026-10-04. Educational research on historical data, not financial advice.

Educational research on historical data only. Not investment advice, not a signal, and never a performance promise. Past results do not predict future performance. Every reference is link-verified before publication and every paper is re-audited weekly against the library's editorial standard. Found an error? Email support@prop-ledger.org and the paper is corrected or withdrawn.