OPEN-SOURCE SCRIPT
volume profile ranking indicator

đ 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)
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)
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità . Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilitĂ
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità . Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilitĂ
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.