Open-Source Pine Script v5 Guide

Anchored VWAP

Institutional execution rules, audit-clean Pine Script v5 source code, and automated multi-ticker scanning.

What Is Anchored VWAP?

Anchored VWAP (AVWAP) is the volume-weighted average price calculated from a specific bar of your choosing - an earnings report, a 52-week low, a gap day, an IPO. Because large funds accumulate positions over days or weeks, the AVWAP from a major event approximates the average cost basis of everyone who bought since that event. Price holding above an anchored VWAP means the average buyer is in profit (supportive); price losing it means the average buyer is underwater (overhead supply). Popularized by Brian Shannon, AVWAP has become one of the most-requested tools on TradingView.

Execution Rules & Setup Playbook

Institutional Playbook: Anchor to the bar of a major event: the last earnings report, a 52-week high or low, or the start of a big-volume breakout. In an uptrend, pullbacks to a rising AVWAP are high-probability buy zones because the average holder since the event is defending their cost basis. A decisive close below an earnings-anchored VWAP tells you post-earnings buyers are trapped - expect rallies to stall there. Pro tip: run two anchors at once (e.g., earnings + 52-week low); where they converge is a major decision level.

Pine Script v5 Source Code

TradingView Pine Editor → Paste → Add to Chart
PINE SCRIPT V5 · UNLOCKED SOURCE
//@version=5
indicator("Anchored VWAP", overlay=true)

// Inputs - click a bar on the chart to set the anchor
anchorTime = input.time(timestamp("01 Jan 2026 09:30 -0500"), "Anchor Point", confirm=true)
src = input.source(hlc3, "Source")

// Cumulative price*volume and volume from the anchor bar
var float cumPV = na
var float cumVol = na

anchored = time >= anchorTime
newAnchor = anchored and not anchored[1]

if newAnchor
    cumPV := src * volume
    cumVol := volume
else if anchored
    cumPV := cumPV + src * volume
    cumVol := cumVol + volume

avwap = anchored and cumVol > 0 ? cumPV / cumVol : na

// Plot
plot(avwap, "AVWAP", color=color.orange, linewidth=2)
plotshape(newAnchor, "Anchor", shape.labelup, location.belowbar, color.orange, text="A", textcolor=color.white, size=size.tiny)

Related Pine Script v5 Guides

Scan Without Coding

Skip single-chart limits — Tradestie monitors this setup across 5,000+ US stocks automatically.

Server-Side Advantage Our interactive stock chart has a built-in live Anchored VWAP tool - one chip with presets for last earnings, 52-week low, and 52-week high, plus click-to-anchor on any bar. You can stack multiple anchors simultaneously, no Pine Script required.
  • Real-time multi-ticker signal scanning
  • Institutional options & GEX confirmation
  • Automated email alerts on triggers
Launch Live Scanner
Check Any Stock Right Now