1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.
Source Code
257 lines of Pine Script v4 from clusters.pine, published under MPL-2.0. Keep the author's credit and licence lines when you reuse it.
clusters.pine
//@version=4
study("Poor man's volume clusters", "PMVolClust", overlay=true, max_bars_back={{max_bars_back}})
block_size = input({{block_size}}, "Bars in profile block", minval=10, maxval={{max_bars_back//3}})
visual_row_width = input({{visual_row_width}}, "Visual row width", minval=10)
show_vpoc = input(true, "Show volume point of control")
filter_size = input({{filter_size}}, "Profile maximum high pass filter size in bars")
use_custom_volume_source = input(false, "Use custom volume source")
volume_source_symbol = input("", "Custom volume source symbol", input.symbol)
BOUNARY_COLOR = color.{{boundary_color}}
{%- for color in block_colors %}
PROFILE{{loop.index}}_COLOR = color.{{color}}
{%- endfor %}
VPOC_COLOR = color.{{vpoc_color}}
custom_volume = use_custom_volume_source ? security(volume_source_symbol, timeframe.period, volume, lookahead=barmerge.lookahead_on) : volume
////
// Calculate profiles
///
block_index = floor(bar_index / block_size)
block_bar = bar_index % block_size
rolling_high = highest(block_bar + 1)
rolling_low = lowest(block_bar + 1)
block_high = rolling_high[block_bar+1]
block_low = rolling_low[block_bar+1]
// plot(block_high, color=color.green)
// plot(block_low, color=color.green)
block_height = (block_high - block_low)
row_height = block_height / {{n_rows}}
n_rows_affected = 0
{% for n in range(n_rows) %}
row{{n}}_low = block_low + row_height * {{n}}
row{{n}}_high = block_low + row_height * {{n+1}}
row{{n}}_price = (row{{n}}_low + row{{n}}_high ) / 2
row{{n}}_value = 0.0
if high[block_size] > row{{n}}_low and low[block_size] < row{{n}}_high
row{{n}}_value := custom_volume[block_size]
n_rows_affected := n_rows_affected + 1
{% endfor %}
{% for n in range(n_rows) -%}
row{{n}}_value := row{{n}}_value / n_rows_affected / row_height
{% endfor %}
// plot(row0_value, color=color.red, style=plot.style_linebr)
if block_bar != 0
{% for n in range(n_rows) -%}
row{{n}}_value := row{{n}}_value + row{{n}}_value[1]
{% endfor %}
float vpoc_price = na
highest_row_value = 0.0
if block_bar == block_size - 1
{% for n in range(n_rows) -%}
if highest_row_value < row{{n}}_value
highest_row_value := row{{n}}_value
vpoc_price := row{{n}}_price
{% endfor %}
else
highest_row_value := highest_row_value[1]
highest_row_value_avg = ema(highest_row_value, filter_size)
// plot(row0_value)
// plot(highest_row_value, color=color.yellow)
// plot(highest_row_value_avg, color=color.blue)
{% for n in range(n_rows) -%}
row{{n}}_width = floor(visual_row_width * row{{n}}_value / highest_row_value_avg[block_bar+1])
{% endfor %}
// plot(row0_value, color=color.red, style=plot.style_linebr, offset=-block_size)
////
// Draw history blocks
///
// draw boudns
bounds_high_y = block_bar != block_size -1 ? block_high[block_bar+1] : na
bounds_low_y = block_bar != block_size -1 ? block_low[block_bar+1] : na
plot(bounds_high_y, color=BOUNARY_COLOR, style=plot.style_linebr, offset=-block_size*2, title="History block high")
plot(bounds_low_y, color=BOUNARY_COLOR, style=plot.style_linebr, offset=-block_size*2, title="History block low")
// draw profile
{% for color in block_colors %}
{% set pn = (loop.length - loop.index + 1) % loop.length + 1 -%}
{% set num_colors = loop.length -%}
history{{pn}}_block_bar = (block_index + {{loop.index}}) % {{num_colors}} * block_size + block_bar
{% for n in range(n_rows) -%}
history{{pn}}_row{{n}}_price = row{{n}}_price[history{{pn}}_block_bar+1]
history{{pn}}_row{{n}}_width = min({{block_size * num_colors - 2}}, row{{n}}_width[history{{pn}}_block_bar+1])
history{{pn}}_row{{n}}_y = history{{pn}}_block_bar <= history{{pn}}_row{{n}}_width ? history{{pn}}_row{{n}}_price : na
{% endfor %}
{% for n in range(n_rows) -%}
plot(history{{pn}}_row{{n}}_y, color=PROFILE{{pn}}_COLOR, style=plot.style_linebr, linewidth=2, offset=-block_size*2, title="History {{pn}} row {{n}}")
{% endfor %}
{% endfor %}
// draw vpoc
vpoc_y = show_vpoc ? vpoc_price : na
plotshape(vpoc_y, title="VPoC", location=location.absolute, color=VPOC_COLOR, style=shape.diamond, size=size.tiny, offset=-block_size*2)
////
// Caclulate and draw last three blocks
///
{% for rn in range(3) -%}
var line recent{{rn}}_high_line = na
var line recent{{rn}}_low_line = na
{% if rn < 2 %}
var label recent{{rn}}_vpoc_label = na
{% endif %}
{% for n in range(n_rows) -%}
var line recent{{rn}}_row{{n}}_line = na
{% endfor -%}
{% endfor %}
if barstate.islast
{% for rn in range(3) -%}
recent{{rn}}_start_i = block_size * {{rn}} + block_bar
recent{{rn}}_end_i = max(block_size * {{rn}} - (block_size - block_bar) + 1, 0)
recent{{rn}}_color_n = (block_index[recent{{rn}}_end_i] + 3) % {{block_colors | length}}
recent{{rn}}_color = {% for color in block_colors -%}
{% if not loop.first %}else {% endif %}if recent{{rn}}_color_n == {{ loop.index - 1 }}
color.{{ color }}
{% endfor %}
if not na(time[recent{{rn}}_start_i]) and recent{{rn}}_start_i - recent{{rn}}_end_i > 5
// high/low bounds
if na(recent{{rn}}_low_line)
recent{{rn}}_low_line := line.new(bar_index, high, bar_index, high, color=BOUNARY_COLOR)
if na(recent{{rn}}_high_line)
recent{{rn}}_high_line := line.new(bar_index, low, bar_index, low, color=BOUNARY_COLOR)
recent{{rn}}_block_high = rolling_high[recent{{rn}}_end_i]
recent{{rn}}_block_low = rolling_low[recent{{rn}}_end_i]
line.set_xloc(recent{{rn}}_low_line, time[recent{{rn}}_start_i], time[recent{{rn}}_end_i], xloc.bar_time)
line.set_y1(recent{{rn}}_low_line, recent{{rn}}_block_low)
line.set_y2(recent{{rn}}_low_line, recent{{rn}}_block_low)
line.set_xloc(recent{{rn}}_high_line, time[recent{{rn}}_start_i], time[recent{{rn}}_end_i], xloc.bar_time)
line.set_y1(recent{{rn}}_high_line, recent{{rn}}_block_high)
line.set_y2(recent{{rn}}_high_line, recent{{rn}}_block_high)
// calculate profile rows
recent{{rn}}_block_height = recent{{rn}}_block_high - recent{{rn}}_block_low
recent{{rn}}_row_height = recent{{rn}}_block_height / {{n_rows}}
{% for n in range(n_rows) -%}
recent{{rn}}_row{{n}}_low = recent{{rn}}_block_low + recent{{rn}}_row_height * {{n}}
recent{{rn}}_row{{n}}_high = recent{{rn}}_block_low + recent{{rn}}_row_height * {{n+1}}
recent{{rn}}_row{{n}}_value = 0.0
{% endfor %}
for i = recent{{rn}}_start_i to recent{{rn}}_end_i + 1
bar_n_rows_affected = 0
{% for n in range(n_rows) -%}
bar_row{{n}}_value = 0.0
if low[i] < recent{{rn}}_row{{n}}_high and high[i] > recent{{rn}}_row{{n}}_low
bar_row{{n}}_value := custom_volume[i]
bar_n_rows_affected := bar_n_rows_affected + 1
{% endfor %}
{% for n in range(n_rows) -%}
recent{{rn}}_row{{n}}_value := recent{{rn}}_row{{n}}_value + bar_row{{n}}_value / bar_n_rows_affected / recent{{rn}}_row_height
{% endfor %}
recent{{rn}}_avg_i = min(recent{{rn}}_start_i + 1 + block_size * {{rn + 2}}, bar_index)
{% for n in range(n_rows) -%}
recent{{rn}}_row{{n}}_price = (recent{{rn}}_row{{n}}_low + recent{{rn}}_row{{n}}_high ) / 2
recent{{rn}}_row{{n}}_width = floor(visual_row_width * recent{{rn}}_row{{n}}_value / highest_row_value_avg[recent{{rn}}_avg_i])
{% endfor %}
// calculate vpoc
float recent{{rn}}_vpoc_price = na
float recent{{rn}}_highes_row_value = 0
{% for n in range(n_rows) -%}
if recent{{rn}}_highes_row_value < recent{{rn}}_row{{n}}_value
recent{{rn}}_highes_row_value := recent{{rn}}_row{{n}}_value
recent{{rn}}_vpoc_price := recent{{rn}}_row{{n}}_price
{% endfor %}
// draw profile rows
{% for n in range(n_rows) -%}
if na(recent{{rn}}_row{{n}}_line)
recent{{rn}}_row{{n}}_line := line.new(bar_index, close, bar_index, close, width=2)
{% endfor %}
{% for n in range(n_rows) %}
line.set_xloc(recent{{rn}}_row{{n}}_line, time[recent{{rn}}_start_i], time_close[max(recent{{rn}}_start_i - recent{{rn}}_row{{n}}_width, 0)], xloc.bar_time)
line.set_y1(recent{{rn}}_row{{n}}_line, recent{{rn}}_row{{n}}_price)
line.set_y2(recent{{rn}}_row{{n}}_line, recent{{rn}}_row{{n}}_price)
line.set_color(recent{{rn}}_row{{n}}_line, recent{{rn}}_color)
{% endfor %}
{% if rn < 2 %}
// draw vpoc
if show_vpoc
if na(recent{{rn}}_vpoc_label)
recent{{rn}}_vpoc_label := label.new(bar_index, close, yloc=yloc.price, style=label.style_diamond, size=size.tiny, color=VPOC_COLOR)
label.set_xloc(recent{{rn}}_vpoc_label, time[recent{{rn}}_start_i + 1], xloc.bar_time)
label.set_y(recent{{rn}}_vpoc_label, recent{{rn}}_vpoc_price)
if not show_vpoc and not na(recent{{rn}}_vpoc_label)
label.delete(recent{{rn}}_vpoc_label)
recent{{rn}}_vpoc_label := na
{% endif %}
0
else
// remove unused lines
if not na(recent{{rn}}_low_line)
line.delete(recent{{rn}}_low_line)
recent{{rn}}_low_line := na
if not na(recent{{rn}}_high_line)
line.delete(recent{{rn}}_high_line)
recent{{rn}}_high_line := na
{% if rn < 2 %}
if not na(recent{{rn}}_vpoc_label)
label.delete(recent{{rn}}_vpoc_label)
recent{{rn}}_vpoc_label := na
{% endif %}
{% for n in range(n_rows) -%}
if not na(recent{{rn}}_row{{n}}_line)
line.delete(recent{{rn}}_row{{n}}_line)
recent{{rn}}_row{{n}}_line := na
{% endfor %}
0
{% endfor %}
Overview
Poor Man's Volume Clusters divides price ranges into discrete horizontal rows, aggregates trading volume per level, and optionally highlights the volume point of control (VPOC). Settings allow adjusting block size, row width, high-pass filter sizing, and specifying an external volume symbol. When an external volume source is enabled, it uses security calls with lookahead enabled, which introduces potential lookahead bias on historical bars.
Volume profile cluster approximation across price rows
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Visual row width
input
{{visual_row_width}}
visual_row_width
Show volume point of control
bool
true
show_vpoc
Profile maximum high pass filter size in bars
input
{{filter_size}}
filter_size
Use custom volume source
bool
false
use_custom_volume_source
Custom volume source symbol
symbol
volume_source_symbol
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
This overlay indicator draws a fixed-range volume profile on the price chart, splitting traded activity into up and down volume at each price level. It also plots a sentiment profile, a developing point of control, and value-area high and low around a configur
The MGIC-tracker is a TradingView indicator that overlays ARK Invest trade records onto stock price charts. It plots buy and sell labels at the exact timestamp of each transaction, showing share volume and ETF weight. Users select a specific ETF type via setti
This overlay indicator marks call and put setups from EMAs, RSI, MACD, and a SPY volume ratio. A call needs higher highs, RSI above its minimum, rising MACD, above-average proxy volume, and a rising trend EMA; a put reverses those tests. Early markers use an E
Comprehensive Volume Profile is an overlay indicator that calculates and plots volume distribution across specified time ranges such as daily sessions, weekly, monthly, or custom bar lengths. It identifies key structural price levels including the Point of Con
This indicator plots two Hull moving averages on the price chart, one of the selected price and one of close, and optionally smooths both with a Kahlman filter. It fills the space between them and marks buy and sell labels when they cross, provided scaled volu
This overlay indicator plots option strike walls and an optional session VWAP on the price chart for SPY or ES. It spaces major strikes by the selected instrument, draws a set number of strikes on each side, and marks wall-trap and sweep events after a cooldow