OPEN-SOURCE SCRIPT

volume profile ranking indicator

1 993
📌 Introduction
This script implements a volume profile ranking indicato for TradingView. It is designed to visualize the distribution of traded volume over price levels within a defined historical window. Unlike TradingView’s built-in Volume Profile, this script gives full customization of the profile drawing logic, binning, color gradient, and the ability to anchor the profile to a specific date.

⚙ How It Works (Logic)
1. Inputs
➀POC Lookback Days (lookback): Defines how many bars (days) to look back from a selected point to calculate the volume distribution.

➀Bin Count (bin_count): Determines how many price bins (horizontal levels) the price range will be divided into.

➀Use Custom Lookback Date (useCustomDate): Enables/disables manually selecting a backtest start date.

➀Custom Lookback Date (customDate): When enabled, the profile will calculate volume based on this date instead of the most recent bar.

2. Target Bar Determination
➀If a custom date is selected, the script searches for the bar closest to that date within 1000 bars.

➀If not, it defaults to the latest bar (bar_index).

➀The profile is drawn only when the current bar is close to the target bar (within ±2 bars), to avoid unnecessary recalculations and performance issues.

3. Volume Binning
➀The price range over the lookback window is divided into bin_count segments.

➀For each bar within the lookback window, its volume is added to the appropriate bin based on price.

➀If the price falls outside the expected range, it is clamped to the first or last bin.

4. Ranking and Sorting
➀A bubble sort ranks each bin by total volume.

➀The most active bin (POC, or Point of Control) is highlighted with a thicker bar.

5. Rendering
➀Horizontal bars (line.new) represent volume intensity in each price bin.

➀Each bar is color-coded by volume heat: more volume = more intense color.

➀Labels (label.new) show:

➀Total volume

➀Rank

➀Percentage of total volume

➀Price range of the bin

đŸ§‘â€đŸ’» How to Use
1. Add the Script to Your Chart
➀Copy the code into TradingView’s Pine Script editor and add it to your chart.

2. Set Lookback Period

➀Default is 252 bars (about one year for daily charts), but can be changed via the input.

3. (Optional) Use Custom Date

●Toggle "Use Custom Lookback Date" to true.

➀Pick a date in the "Custom Lookback Date" input to anchor the profile.

4. Analyze the Volume Distribution

➀The longest (thickest) red/orange bar represents the Point of Control (POC) — the price with the most volume traded.

➀Other bars show volume distribution across price.

➀Labels display useful metrics to evaluate areas of high/low interest.

✅ Features
đŸ”¶ Customizable anchor point (custom date).

đŸ”¶Adjustable bin count and lookback length.

đŸ”¶ Clear visualization with heatmap coloring.

đŸ”¶ Lightweight and performance-optimized (especially with the shouldDrawProfile filter)

Haftungsausschluss

Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von RatschlÀgen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.