OPEN-SOURCE SCRIPT
Updated Auto Anchored VP - True TPO Logic

Auto Anchored VP — True TPO Logic
This indicator is an open-source attempt to replicate TradingView's native Anchored Volume Profile as closely as possible within the constraints of Pine Script. It is published for educational purposes — both as a useful tool and as a reference for understanding why accurate volume profile calculation is difficult to achieve in Pine Script.
The Problem — Why Pine Script Cannot Build a True AVP
TradingView's native Anchored Volume Profile is calculated on the backend in Java, with access to tick-by-tick trade data. Every individual transaction is placed at its exact price, producing a true tick-level volume distribution. This is the gold standard — the most accurate possible representation of where volume actually traded.
Pine Script does not have access to tick data. It only sees OHLCV bars — one open, high, low, close, and volume value per candle. There is no way to know, within Pine Script, how much of a bar's volume traded at 76,200 versus 76,800. This is a hard platform limitation, not a solvable coding problem.
As a result, every Pine Script volume profile implementation is an approximation. The question is not whether it is perfect — it cannot be — but how close it can get.
The Approach — Even TPO Distribution
This indicator takes the most statistically neutral approach available in Pine Script: each bar's volume is distributed evenly across every price bin it spans based on its high-low range.
If a bar trades from 75,000 to 77,000 and covers 10 bins, each bin receives one tenth of that bar's volume. This makes no assumptions about where within the bar the volume concentrated — it treats every price the bar visited as equally likely. Across hundreds of bars, this averaging effect produces a profile that closely approximates the true tick-level distribution.
The chart above shows both profiles side by side. The levels are close but not identical — the difference is the gap between tick-level precision and bar-level approximation. For most practical trading purposes the levels are functionally equivalent.
The Dual-Bin Value Area Algorithm
The Value Area expansion uses the standard dual-bin comparison — at each step, the combined volume of the next 2 bins above is compared against the next 2 bins below, and the Value Area expands toward whichever side has more volume. This matches the original Steidlmayer methodology used in professional TPO profiles and is the same logic TradingView's backend applies.
How to Read the Levels
Why Previous Week
The anchor covers the complete prior weekly range — a fully closed, committed profile. The current week's profile is incomplete until Friday close. Reacting to a closed profile means every level has been fully tested and accepted by the market.
Settings
This indicator is an open-source attempt to replicate TradingView's native Anchored Volume Profile as closely as possible within the constraints of Pine Script. It is published for educational purposes — both as a useful tool and as a reference for understanding why accurate volume profile calculation is difficult to achieve in Pine Script.
The Problem — Why Pine Script Cannot Build a True AVP
TradingView's native Anchored Volume Profile is calculated on the backend in Java, with access to tick-by-tick trade data. Every individual transaction is placed at its exact price, producing a true tick-level volume distribution. This is the gold standard — the most accurate possible representation of where volume actually traded.
Pine Script does not have access to tick data. It only sees OHLCV bars — one open, high, low, close, and volume value per candle. There is no way to know, within Pine Script, how much of a bar's volume traded at 76,200 versus 76,800. This is a hard platform limitation, not a solvable coding problem.
As a result, every Pine Script volume profile implementation is an approximation. The question is not whether it is perfect — it cannot be — but how close it can get.
The Approach — Even TPO Distribution
This indicator takes the most statistically neutral approach available in Pine Script: each bar's volume is distributed evenly across every price bin it spans based on its high-low range.
If a bar trades from 75,000 to 77,000 and covers 10 bins, each bin receives one tenth of that bar's volume. This makes no assumptions about where within the bar the volume concentrated — it treats every price the bar visited as equally likely. Across hundreds of bars, this averaging effect produces a profile that closely approximates the true tick-level distribution.
The chart above shows both profiles side by side. The levels are close but not identical — the difference is the gap between tick-level precision and bar-level approximation. For most practical trading purposes the levels are functionally equivalent.
The Dual-Bin Value Area Algorithm
The Value Area expansion uses the standard dual-bin comparison — at each step, the combined volume of the next 2 bins above is compared against the next 2 bins below, and the Value Area expands toward whichever side has more volume. This matches the original Steidlmayer methodology used in professional TPO profiles and is the same logic TradingView's backend applies.
How to Read the Levels
- POC — Point of Control
The price bin with the highest volume for the previous week. The market's fairest price. Price gravitates back toward it when it deviates. - VAH — Value Area High
The upper boundary of the 70% volume zone. Acts as support when price is above it, resistance when price breaks below and retests from underneath. - VAL — Value Area Low
The lower boundary of the 70% volume zone. Acts as resistance on rallies from below, support when price holds above it.
Why Previous Week
The anchor covers the complete prior weekly range — a fully closed, committed profile. The current week's profile is incomplete until Friday close. Reacting to a closed profile means every level has been fully tested and accepted by the market.
Settings
- Number of Rows — bin resolution. 200 is the recommended default balancing precision and performance.
- Value Area % — standard is 70%.
- Colors — fully customizable.
Release Notes
The visuals got improved, now the labels are gone, lines extend right a little more and VAL and VAH lines are dashed.Release Notes
Forgot to update the chart in the previous patch, now updated the chartOpen-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Confluencer
Systematic & Discretionary Trader
Building precision tools for serious market analysis.
The Confluence Array — Indicator Suite for futures, crypto & forex traders.
Systematic & Discretionary Trader
Building precision tools for serious market analysis.
The Confluence Array — Indicator Suite for futures, crypto & forex traders.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Confluencer
Systematic & Discretionary Trader
Building precision tools for serious market analysis.
The Confluence Array — Indicator Suite for futures, crypto & forex traders.
Systematic & Discretionary Trader
Building precision tools for serious market analysis.
The Confluence Array — Indicator Suite for futures, crypto & forex traders.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.