OPEN-SOURCE SCRIPT

3D Volume Profile [UAlgo]

2 068
3D Volume Profile is a chart based volume profile indicator that takes a classic horizontal profile concept and presents it as a pseudo 3D structure directly on price. Instead of drawing flat histogram bars only, the script renders each profile row as a shaded 3D block with a front face, a side face, and a top face, which creates a stronger visual sense of depth and distribution.

The indicator runs on price (overlay=true) and builds a rolling volume profile over a user defined lookback window. It divides the recent price range into fixed bins, distributes candle volume across those bins, identifies the Point of Control and the Value Area, and then draws the result on the right side of the chart. Each row is color coded by dominant flow direction, which means the profile can show whether a bin was more buy dominated or sell dominated in addition to showing how much total volume accumulated there.

This makes the tool useful for traders who want more than a basic profile display. It combines:
A rolling horizontal volume profile
Buy versus sell dominance shading
Point of Control and Value Area detection
A forward projected 3D style histogram
Clear POC, VAH, and VAL reference lines on the chart

The final result is a visually rich profile tool designed for fast structural reading, especially when identifying acceptance zones, thin areas, and dominant participation regions.

🔹 Features

🔸 1) Rolling Volume Profile Over a Recent Window

The script builds a rolling profile from the most recent user selected number of bars. This means the profile continuously adapts as new bars come in, making it more useful for current market structure analysis than a fixed session only approach.

🔸 2) 3D Style Histogram Rendering

Each volume row is drawn as a pseudo 3D block rather than a flat rectangle. The script creates:
A front face
A side face
A top face

The side and top faces are shaded versions of the main color, which gives the profile a depth effect and makes the structure easier to read visually.

🔸 3) Customizable 3D Depth in X and Y

The 3D effect is controlled with two settings:
3D Depth X, which controls how far the rear face is shifted horizontally in bars
3D Depth Y, which controls how far the rear face is shifted vertically as a percentage of row height

This allows the user to make the profile look flatter or more pronounced depending on preference.

🔸 4) Buy and Sell Volume Dominance Coloring

Each bin tracks both buy volume and sell volume. If buy volume is greater than or equal to sell volume, the row uses the bullish color. If sell volume dominates, the row uses the bearish color.

This means the profile is not only a measure of total activity. It also adds directional context to each price zone.

🔸 5) Point of Control Detection

The script identifies the row with the highest total volume and marks it as the Point of Control. The POC is highlighted with its own dedicated color and is visually distinct from the rest of the profile.

This gives traders an immediate reference for the most active price zone in the rolling range.

🔸 6) Value Area Calculation

The indicator calculates a Value Area around the Point of Control based on the user selected percentage. Bins inside the Value Area are marked and recolored with the Value Area color, which makes the high participation region easy to identify.

🔸 7) Forward Projected Profile Layout

The profile is drawn to the right of current price using a configurable offset. This keeps the active candle area readable while still placing the profile in a clear and accessible location.

🔸 8) Adjustable Resolution and Width

Users can control:
The lookback length
The number of profile rows
The maximum width of the histogram
The right side offset

This makes the indicator suitable for both coarse structural analysis and more detailed profile inspection.

🔸 9) POC, VAH, and VAL Reference Lines

After the profile is built, the script calculates the POC, Value Area High, and Value Area Low, then projects horizontal reference lines across the chart. Labels are placed to the right so the key levels are clearly marked.

🔸 10) Row by Row Dominance and Acceptance Reading

Because each row stores total volume, buy volume, sell volume, Value Area membership, and POC status, the indicator gives a layered view of the market:
Where the most activity occurred
Which zones were accepted
Which zones were dominated by buyers
Which zones were dominated by sellers

🔸 11) Premium Visual Presentation

The script uses shaded faces, dedicated POC highlighting, Value Area recoloring, and clean right side labels. This makes it more presentation focused than a basic flat profile and improves chart readability for manual analysis.

🔹 Calculations

1) Profile Range Detection

The script first finds the highest high and lowest low inside the active lookback window. This defines the full vertical range of the volume profile. Only the most recent bars inside that window are used for profile construction.

2) Bin Initialization

Once the recent range is known, the script divides that price range into the chosen number of bins. Each bin stores:
Top boundary
Bottom boundary
Total volume
Buy volume
Sell volume
Flags for Value Area and POC

The bin size is calculated by dividing the total price range by the number of rows.

3) Volume Distribution Across Price Bins

For each candle, the script determines which bins the candle spans. It then spreads that candle’s volume evenly across all touched bins.

This is important because the script does not place the full candle volume into a single price level. Instead, it allocates the candle volume across the portion of the profile that candle covers.

Important implementation note:
This script uses equal distribution across the spanned bins, not proportional overlap weighting. That means each touched row receives the same share of the candle’s volume.

4) Buy Versus Sell Volume Classification

The script classifies each candle as buy dominated or sell dominated using candle direction:
If close is greater than or equal to open, the candle is treated as buy volume
If close is below open, the candle is treated as sell volume

That candle’s allocated volume is then added to either volBuy or volSell inside each touched bin.

This is a practical directional approximation, not true bid ask tape volume.

5) Total Volume and POC Detection

After all candles are processed, the script scans every bin and calculates:
The total volume across the profile
The maximum single bin volume
The POC index

The POC is the bin with the highest total volume. That bin is marked as both isPOC and isVA before Value Area expansion begins.

6) Value Area Expansion Logic

The Value Area is built around the POC by expanding upward and downward until the selected percentage of total profile volume is included.

The script compares the next bin above and the next bin below the current Value Area. It adds whichever side has greater volume first. This continues until cumulative included volume reaches the target Value Area percentage.

This creates a standard profile style Value Area centered on the highest participation region.

7) Histogram Width Normalization

Each row’s width is scaled relative to the maximum volume row:
The row with the most volume becomes the widest
Smaller rows are scaled proportionally

This means width directly communicates relative participation at each price zone.

8) Color Selection Logic

For each bin, the script first determines whether buy volume or sell volume dominates:
If buy volume is greater than or equal to sell volume, it uses the bullish color
Otherwise it uses the bearish color

Then the script overrides that base direction color if needed:
If the row is the POC, it uses the POC color
If the row is inside the Value Area, it uses the Value Area color

This gives the profile a clear visual hierarchy:
POC first
Value Area second
Directional dominance otherwise

9) 3D Face Construction

Each row is rendered as a pseudo 3D object using:
A front rectangle
A shifted back edge using the X and Y depth settings
A side face when horizontal depth is visible
A top or bottom face depending on vertical depth direction

The script shades the side face darker and the top face brighter than the base color to create a depth illusion.

This is a visual projection technique, not a true 3D engine, but it produces a convincing 3D profile effect on the chart.

10) Rendering Order Logic

The script changes draw order depending on the sign of the Y depth:
If vertical depth is positive, rows are drawn from bottom to top
If vertical depth is negative, rows are drawn from top to bottom

This helps the 3D faces stack more cleanly and reduces visual overlap issues.

11) POC, VAH, and VAL Price Calculation

After the profile is complete:
The POC price is the midpoint of the POC bin
VAH is the highest top boundary among all Value Area bins
VAL is the lowest bottom boundary among all Value Area bins

These levels are then drawn as horizontal lines extending from the left side of the lookback window toward the right side label area.

12) Label Placement

The labels for POC, VAH, and VAL are placed slightly to the right of the profile. This keeps them readable and avoids overlap with the 3D bars themselves.

כתב ויתור

המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.