OPEN-SOURCE SCRIPT

VWAP Auto Anchored Trend

1 231
VWAP Auto Anchored Trend

This indicator is a Pine Script v6 recreation of an auto-anchored VWAP tool with an added trend and flatness readout. It is designed to help you study how volume-weighted price develops from a selected anchor and how stable or directional that VWAP remains over time.

What It Does

At its core, this script calculates a Volume Weighted Average Price (VWAP). Unlike a simple moving average, VWAP gives more influence to bars with higher volume. That allows it to reflect where trading activity has been concentrated during the active anchor period.

The line begins at the selected anchor and updates forward from there, giving you a focused view of how price and volume have behaved from that point.

Anchor Periods

The script supports multiple anchor types, including:

  • Auto
  • Highest High
  • Lowest Low
  • Highest Volume
  • Session
  • Week
  • Month
  • Quarter
  • Year
  • Decade
  • Century
  • Earnings
  • Dividends
  • Splits


For time-based anchors such as Month, Quarter, or Year, the indicator displays only the currently active anchor period. That keeps the chart focused on the most recent cycle rather than extending the VWAP through the entire chart history.

Source and Calculation

The VWAP can be calculated from a selectable source, such as hlc3, which is commonly used as a balanced price basis. The script accumulates price multiplied by volume, then divides that running total by cumulative volume over the active anchor period.

This makes the line responsive not only to price movement, but to how much trading participation occurred at those prices.

Bands and Visual Structure

The script includes optional upper and lower VWAP bands. These bands can be calculated using:

  • Standard Deviation
  • Percentage


Up to three band levels can be enabled, each with its own multiplier. When active, they can help frame how tightly or loosely price is trading around the anchored VWAP.

A background fill can also be used between the outer visible bands to make the VWAP zone easier to read visually.

Offset Support

An offset setting is included so the VWAP and its bands can be shifted visually on the chart. This affects display placement only and does not change the underlying VWAP calculation.

VWAP Flatness and Trend Readout

One of the main additions in this version is the VWAP Flatness section.

Instead of only judging the VWAP slope by eye, the script measures how much the VWAP has drifted from its anchor to the current bar. It then normalizes that drift using ATR to produce a more comparable trend/flatness reading.

The table compares two views:

  • All Period - the entire active anchor period
  • Last 50% - the most recent half of that same period


This can help show whether the VWAP has remained balanced over the full anchor period, or whether the more recent portion has started to trend more clearly.

Table Readout Includes

  • VWAP State - VERY FLAT, FLAT, MODERATE, TRENDING, or STRONG TREND
  • ATR Score - VWAP drift measured against ATR
  • Drift % - total percentage drift in VWAP over the measured section
  • Per Bar % - average drift per bar over that section


This is intended as a structured way to describe VWAP behavior. It does not predict future price movement, but it can help organize how stable or directional the VWAP has been within the chosen anchor window.

How It May Be Used

This indicator can be used as a reference for:

  • Tracking where volume-weighted price has developed from an anchor
  • Comparing current price to anchored average value
  • Observing whether price is staying near VWAP or expanding away from it
  • Viewing optional VWAP band structure
  • Comparing overall VWAP behavior with the most recent half of the anchor period


Notes

  • This script is intended as a charting and analysis tool.
  • The flatness and trend labels describe measured VWAP behavior, not guarantees.
  • Different symbols, timeframes, and anchor periods can produce very different readings.


Summary

This script combines anchored VWAP logic, optional bands, and a two-part flatness/trend readout into one tool. Its goal is to help you study where weighted price has developed, how price is behaving around that value, and whether the VWAP itself has remained relatively flat or become more directional over the active anchor period.

면책사항

해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.