Indicator · Pine Script v6 · Own pane

Volume Delta Histogram

by piecioshka

Volume Delta Histogram calculates real volume delta (buy volume minus sell volume) from footprint data and displays it as a histogram in a separate pane.

View on GitHub

GitHub stars2on the repository
Pine versionv6current
Lines of code85
Settings11inputs
LicenceMIT
Last update12 days ago18 Oct 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

85 lines of Pine Script v6 from indicators-premium/volume/volume-delta-histogram/volume-delta-histogram.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

volume-delta-histogram.pine
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Piotr Kowalski "piecioshka"
// Docs (EN): https://github.com/piecioshka/tradingview-pine-scripts/blob/main/indicators-premium/volume/volume-delta-histogram/volume-delta-histogram.md
// Docs (PL): https://github.com/piecioshka/tradingview-pine-scripts/blob/main/indicators-premium/volume/volume-delta-histogram/volume-delta-histogram.pl.md

//@version=6
indicator('Volume Delta Histogram', overlay=false, max_labels_count=500)

// Volume delta histogram (from real footprint data) in a separate panel, anchored to the base (0).
// Column = |delta| (buy − sell), colored by sign: green = buy dominance, red = sell.
// The height is normalized and capped at a given % of the panel; real delta values are
// visible as numbers on the columns and in the data window.
// Requires Premium/Ultimate; no footprint data (e.g. some crypto) → shows nothing.

gDelta = 'Column colors'
cBuy  = input.color(color.new(color.rgb(38, 166, 154), 50), 'Positive delta color (buy)', group=gDelta)
cSell = input.color(color.new(color.rgb(239, 83, 80), 50), 'Negative delta color (sell)', group=gDelta)

gView = 'Display'
diverge    = input.bool(true, 'Red columns grow downward', tooltip='When enabled, negative-delta (sell) columns grow downward from the zero line and positive (buy) ones upward — a diverging layout.', group=gView)
showLabels = input.bool(true, 'Show delta numbers', tooltip='Delta number printed next to each column.', group=gView)
txtUp    = input.color(color.new(color.rgb(38, 166, 154), 0), 'Number color — positive delta', group=gView, tooltip='Number color for positive delta. Defaults to the up-column color.')
txtDown  = input.color(color.new(color.rgb(239, 83, 80), 0),  'Number color — negative delta', group=gView, tooltip='Number color for negative delta. Defaults to the down-column color.')
fontSize = input.string('Small', 'Number size', options=['Tiny', 'Small', 'Normal', 'Large'], group=gView)
numPos   = input.string('Above column', 'Number position', options=['Above column', 'At the bottom'], tooltip='"Above column" = slightly above the column. "At the bottom" = at the panel base.', group=gView)
numGap   = input.float(0.5, 'Number gap above column (% of panel)', minval=0, maxval=20, step=0.5, tooltip='Vertical gap between the number and the column tip, as a % of panel height (applies to "Above column").', group=gView)

gNorm = 'Column normalization'
normPow  = input.float(0.5, 'Height normalization', minval=0.1, maxval=1, step=0.05, tooltip='Power scaling the column height: 1 = linear (no normalization), 0.5 = square root, lower = stronger compression of spikes. Reference: max of ~500 candles.', group=gNorm)
fillPct  = input.float(100, 'Max column height (% of panel)', minval=5, maxval=100, step=5, tooltip='The tallest column takes up at most this % of panel height (the rest stays empty). 100 = fills the panel.', group=gNorm) / 100.0

// --- K/M/B abbreviation; below 1000 an integer (no ".00") ---
f_abbr(float x) =>
    a = math.abs(x)
    a >= 1e9 ? str.tostring(x / 1e9, '#.##') + 'B' : a >= 1e6 ? str.tostring(x / 1e6, '#.##') + 'M' : a >= 1e3 ? str.tostring(x / 1e3, '#.#') + 'K' : str.tostring(x, '#')

fp = request.footprint(1)        // ticks_per_row irrelevant for the delta total
hasData = not na(fp)
float delta   = na
float buyVol  = na
float sellVol = na
if hasData
    delta   := fp.delta()
    buyVol  := fp.buy_volume()
    sellVol := fp.sell_volume()

totalVol = hasData ? buyVol + sellVol : na
hasDelta = hasData and not na(totalVol) and totalVol > 0   // no real trades → show nothing
if not hasDelta
    delta   := na
    buyVol  := na
    sellVol := na

mag        = na(delta) ? na : math.abs(delta)
magN       = na(mag) ? na : math.pow(mag, normPow)   // normalized HEIGHT (power < 1 compresses spikes)
maxN       = ta.highest(nz(magN), 500)               // max of ~500 candles → reference for the "ceiling"
deltaColor = not hasDelta ? na : delta >= 0 ? cBuy : cSell

// Column (base 0) + an invisible "ceiling" capping the height: the tallest column ≈ fillPct of the panel.
// The column and the "ceiling" live only in the panel — their values must NOT show at the cursor (the height is normalized).
isDown = diverge and not na(delta) and delta < 0   // sell column drawn downward (diverging layout)
barN   = na(magN) ? na : (isDown ? -magN : magN)
plot(barN, 'Delta (norm.)', color=deltaColor, style=plot.style_columns, histbase=0, display=display.pane)
plot(maxN > 0 ? maxN / fillPct : na, 'Ceiling', color=color.new(color.gray, 100), editable=false, display=display.pane)
plot(diverge and maxN > 0 ? -maxN / fillPct : na, 'Floor', color=color.new(color.gray, 100), editable=false, display=display.pane)
// REAL delta at the cursor (status line) + data window; buy/sell in the data window
plot(delta,   'Delta',      color=deltaColor, format=format.volume, display=display.status_line + display.data_window)
plot(buyVol,  'Buy (ask)',  color=cBuy,       format=format.volume, display=display.data_window)
plot(sellVol, 'Sell (bid)', color=cSell,      format=format.volume, display=display.data_window)

// Numbers (signed delta) — above the column or at the base
szLbl  = fontSize == 'Tiny' ? size.tiny : fontSize == 'Small' ? size.small : fontSize == 'Normal' ? size.normal : size.large
lblGap = maxN / fillPct * (numGap / 100)   // gap above the column (% of panel height, configurable)
// Labels on every candle with data — TradingView keeps the last 500 (auto-trim when scrolling)
// Number color by delta sign — separate colors for positive/negative (defaults match the columns)
if showLabels and not na(delta)
    lblColor = delta >= 0 ? txtUp : txtDown
    tip      = isDown ? -magN : magN                                   // column tip (accounts for direction)
    // "Above column" = at the tip; "At the bottom" = at the zero line (red ones above the downward column)
    anchor   = numPos == 'Above column' ? tip : 0
    below    = numPos == 'Above column' ? isDown : (diverge ? not isDown : false)  // should the text go below the anchor
    // Directional style with a transparent background: pushes the WHOLE text past the anchor (no overlap with the column)
    lblStyle = below ? label.style_label_up : label.style_label_down
    lblY     = anchor + (below ? -lblGap : lblGap)
    label.new(bar_index, lblY, text=f_abbr(delta), yloc=yloc.price, style=lblStyle, color=color.new(color.white, 100), textcolor=lblColor, size=szLbl)

Overview

Positive delta columns represent buy dominance, while negative delta columns represent sell dominance. Users can customize colors, enable a diverging layout where negative columns extend downward, and display abbreviated numerical delta labels above or below columns. Column heights can be normalized using power scaling to compress large volume spikes. It requires a TradingView plan with footprint data support.

Details

Published by

piecioshka on GitHub

Draws

Separate pane below the chart

Category

Volume

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

pinescriptpinescript-indicatorspinescript-strategiestradingtradingview

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Positive delta color (buy)colorcolor.new(color.rgb(38, 166, 154), 50)cBuy
Negative delta color (sell)colorcolor.new(color.rgb(239, 83, 80), 50)cSell
Red columns grow downwardbooltruediverge
Show delta numbersbooltrueshowLabels
Number color — positive deltacolorcolor.new(color.rgb(38, 166, 154), 0)txtUp
Number color — negative deltacolorcolor.new(color.rgb(239, 83, 80), 0)txtDown
Number sizestringSmallfontSize
Number positionstringAbove columnnumPos
Number gap above column (% of panel)float0.5numGap
Height normalizationfloat0.5normPow
Max column height (% of panel)float100fillPct
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.

Similar Pine Scripts

Money Flow Index

by everget
947 stars

Calculates the standard Money Flow Index (MFI) oscillator alongside an exponential moving average signal line in a separate pane. The script visually highlights trend conditions through dynamic ribbon filling, optional difference histogram bars, and overbought

Indicator v4 Oscillators & momentumVolume
Updated 12 days ago · GPL-3.0 GitHub repository of Money Flow Index

This indicator plots a Supertrend-based trend-following setup in a separate pane and skips conditions it treats as a sideways market. A volatility range is built from an ATR value, with RMA, SMA, EMA, or WMA smoothing, or from a fixed point distance. Optional

Indicator v5 TrendVolatility & bands
Updated 1 year ago · MPL-2.0 GitHub repository of Trend Following Setup - Sideways Market Skipper
550 stars

Range Volume Change compares volume inside a chosen session window with the same window on the previous day and plots that change as a percentage. It accumulates volume during the window and, when enabled, volume outside it, drawing growing columns in a separa

Indicator v5 VolumeSessions & time Repaints
Updated 10 months ago · None stated GitHub repository of Range Volume Change
257 stars

This indicator builds a footprint of estimated buy and sell volume across price rows and plots it in a separate pane. It fills rows from bar low to high, stores volume per row, and draws buy and sell volume boxes, volume-profile boxes, row labels, and cumulati

Indicator v5 Volume Repaints
Updated 7 weeks ago · None stated GitHub repository of Footprint Delta Lite

Commitment Gauge

by harryguiacorn
220 stars

This indicator measures directional momentum by evaluating candlestick body proportions and volume over a user-defined lookback window. It computes the ratio of candle body to total range, weights the cumulative value by volume and absolute body size, and dete

Indicator v4 VolumeCandlestick patterns
Updated 1 year ago · None stated GitHub repository of Commitment Gauge

Aggregate Signal

by capissimo
114 stars

This indicator builds an aggregate oscillator in a separate pane. It scales open, high, low, close, and volume into a 0 to 1 range, then averages scaled readings from MACD, a MACD histogram, RSI, stochastic, CCI, momentum, OBV, a directional index, volume-weig

Indicator v4 Oscillators & momentumVolume Repaints
Updated 1 year ago · None stated GitHub repository of Aggregate Signal

More Volume scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers