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)
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die FunktionalitĂ€t ĂŒberprĂŒfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
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.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die FunktionalitĂ€t ĂŒberprĂŒfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
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.