Ultimate Clusters Volume Profile [Quantum Edge]Anchored Clusters Volume Profile is a machine-learning-powered volume analysis tool built by Quantum Edge Capital LLC that combines K-Means clustering with per-cluster volume profiling to reveal how institutional volume is distributed across distinct price regimes within any user-defined time range. Instead of one aggregate profile, you get N separate volume profiles — one for each behavioral price cluster — showing exactly where volume concentrated inside each zone the market spent meaningful time.
This is the only volume profile tool that tells you not just where volume traded, but which market regime that volume belongs to.
⚙️ How It Works
Step 1 — Anchor the Range
You define a start time and end time directly on the chart using TradingView's built-in time picker (triggered on first load via confirm = true). Every bar within that window is included in the analysis. The selected range is highlighted with a configurable background color so the analysis boundary is always visible.
Step 2 — K-Means Clustering
The indicator runs a full volume-weighted K-Means clustering algorithm on every bar inside the range:
Price data is collected as hl2 (mid-price) with corresponding volume for each bar
K initial centroids are distributed evenly across the price range
For each iteration, every bar is assigned to its nearest centroid by absolute price distance
Centroids are recalculated as the volume-weighted average price of all bars assigned to that cluster
This repeats for the configured number of iterations (default: 50), converging the centroids to the true volume-weighted center of each price regime
The result: N clusters, each representing a distinct price zone where the market spent concentrated time and volume during the selected period.
Step 3 — Per-Cluster Volume Profile
For each cluster, a separate volume histogram is computed:
The cluster's price range (full high-to-low across all assigned bars) is divided into configurable rows (default: 20 bins per cluster)
Volume is distributed across bins proportionally to how much of each bar's wick intersects each bin — a more accurate distribution method than simple close-price bucketing
The Point of Control (POC) for each cluster is identified as the highest-volume bin
A dashed horizontal line extends from the start of the range to the profile for each cluster's POC
POC bins are rendered at full color opacity; all other bins are rendered at 75% transparency
Step 4 — Labeling & Annotation
Each cluster profile displays:
POC Volume label — The volume of the highest-concentration bin, anchored at the left edge of the range
Total Cluster Volume label — Cumulative volume for the entire cluster, displayed to the right of the profile
Price dots (optional) — Each bar assigned to a cluster is marked with a colored dot at its mid-price, showing the spatial distribution of cluster membership across the chart
Each cluster uses a unique color from a 10-color preset palette (Blue, Red, Green, Orange, Purple, Cyan, Yellow, Pink, Brown, Blue Grey) for instant visual separation.
🛠️ Settings
Group Setting Default Description
Anchor Settings Start Time 2024-01-01 Range start — confirmed visually on chart load
Anchor Settings End Time 2025-01-01 Range end — confirmed visually on chart load
Anchor Settings Range Highlight Gray (90% transp.) Background color for the selected range
Clustering Settings Number of Clusters 5 K value — how many price regimes to detect (2–10)
Clustering Settings K-Means Iterations 50 Convergence iterations (5–50)
Volume Profile Rows per Cluster VP 20 Histogram bins per cluster profile
Volume Profile Max VP Width (Bars) 40 Maximum bar width of the widest profile bin
Volume Profile VP Offset 10 Gap in bars between last bar and profile start
Volume Profile Highlight Price Dots On Color-coded dot at each bar's cluster mid-price
Volume Profile Dot Size Small Tiny / Small / Normal / Large / Huge
📋 How to Use
Select your range around a key market period — Anchor the range to a complete auction cycle: a prior consolidation range, a trending leg, a quarterly period, or an earnings-to-earnings window. The quality of your clustering depends entirely on capturing a meaningful behavioral window.
Read cluster separation as regime structure — Clusters that are tightly packed near the same price = compression or value area. Clusters spread vertically = trending distribution across distinct price levels. Wide vertical separation between clusters = strong directional delivery with minimal overlap between regimes.
Use cluster POCs as institutional reference levels — Each cluster's POC is the volume-weighted center of that price regime. These levels act like mini-anchored VWAPs for each zone and tend to attract price on retests. Mark these levels and treat them as high-probability reaction points.
Compare cluster volume totals for directional bias — If the highest-volume clusters are concentrated in the upper portion of the range, institutional activity favored higher prices. Dominance in lower clusters suggests bearish accumulation or distribution.
Use price dots to confirm assignment quality — A clean cluster should show dots tightly grouped in a price band. Scattered or interleaved dots between adjacent clusters indicate overlap — consider reducing K or widening the range for better separation.
Increase iterations for cleaner results on wide ranges — On ranges covering hundreds of bars or large price swings, set iterations to 50 (maximum) to ensure centroids fully converge. On shorter, tighter ranges, 20–30 iterations is sufficient.
Tune K to the market context — For a tight consolidation range, 3–4 clusters is optimal. For a full trending leg covering multiple structural phases (accumulation, markup, distribution, markdown), 5–7 clusters better separates the distinct regimes.
⚠️ Notes
Built in Pine Script v6.
All calculations run on barstate.islast — the full K-Means algorithm and all profile rendering execute on the final bar. The chart fully redraws on each new bar close as expected.
TradingView's 500-label limit is managed via a priority system: volume metric labels (POC and Total per cluster) are reserved first; remaining label budget is allocated to price dots in order of recency.
The 500-box limit is also actively managed — if the profile box count approaches the limit, rendering stops gracefully rather than throwing errors.
Volume distribution uses wick-proportional interpolation across bins rather than simple close-price bucketing, producing a more accurate profile shape that reflects actual traded range, not just closing levels.
K-Means is a non-deterministic algorithm in theory, but the even-spacing initialization used here produces consistent, reproducible results across chart reloads for the same time range.
For best performance on large ranges (500+ bars), use a higher timeframe chart. The algorithm loops through every bar in the range on each recalculation.
© Quantum Edge Capital LLC. Licensed under CC BY-NC-SA 4.0. Non-commercial use only.
อินดิเคเตอร์ Pine Script®









