Indicator · Pine Script v6 · On the chart

Accumulation / Distribution Density (VD)

by piecioshka

This indicator plots accumulation and distribution markers on the price chart.

View on GitHub

GitHub stars2on the repository
Pine versionv6current
Lines of code69
Settings8inputs
LicenceMIT
Last update10 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

69 lines of Pine Script v6 from indicators/volume/accumulation-distribution-density/accumulation-distribution-density.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

accumulation-distribution-density.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/volume/accumulation-distribution-density/accumulation-distribution-density.md
// Docs (PL): https://github.com/piecioshka/tradingview-pine-scripts/blob/main/indicators/volume/accumulation-distribution-density/accumulation-distribution-density.pl.md

//@version=6
indicator('Accumulation / Distribution Density (VD)', overlay=true)

// Accumulation / distribution density (VD) — modeled after Mieczyslaw Siudek's indicator from xStation (XTB).
// Looks for candles whose volume-to-price-movement ratio (density = volume per unit of range)
// is disproportionately high and which set a local extreme. Heavy turnover with little movement
// at a low/high suggests position accumulation/distribution and a potential turning point.
// Marker below a candle = accumulation density  (potential bullish signal),
// marker above a candle = distribution density  (potential bearish signal).
// Each marker is a plotshape, so the Style tab gives it its own visibility checkbox,
// shape picker, position (above/below bar) dropdown, and color — per signal.
// By default signals are evaluated only on closed candles (no repainting); with the
// "Signal on closed candle only" option off, a signal on an unclosed candle may disappear
// before it closes (conditions use live values).

g = 'Parameters'
lenExtreme    = input.int(5, 'Max/Min of (bars)', minval=1, group=g, tooltip='Number of previous candles against which the signal candle must set a new low (accumulation) or a new high (distribution).')
lenSpread     = input.int(5, 'Average Spread of (bars)', minval=1, group=g, tooltip='Number of candles for the average range (high − low).')
lenDensity    = input.int(5, 'Average Density of (bars)', minval=1, group=g, tooltip='Number of candles for the average density (volume / range).')
useSpread     = input.bool(true, 'Spread condition', group=g, tooltip='Require the signal candle range not to exceed Spread Factor × average range (the candle must not be too big — density means heavy turnover with LITTLE movement).')
spreadFactor  = input.float(1.4, 'Spread Factor', minval=0.1, step=0.1, group=g, tooltip='How much larger the signal candle range may be than the average for a signal to appear.')
densityFactor = input.float(2, 'Density Factor', minval=1.0, step=0.1, group=g, tooltip='How much the signal candle density must exceed the average density.')
closePct      = input.int(0, 'Bar close (%)', minval=0, maxval=100, group=g, tooltip='Filter on the close position within the candle range: for accumulation the close must be at least X% above the low, for distribution at least X% below the high. 0 disables the filter.')
onlyConfirmed = input.bool(true, 'Signal on closed candle only', group=g, tooltip='Evaluate signals only when a candle closes - a marker never appears and then disappears on the live candle (no repainting). Turn off to watch signals form in real time on the unclosed candle.')

spread  = high - low
density = volume / math.max(spread, syminfo.mintick)   // volume per unit of movement; a zero-range doji → volume per 1 tick

// Averages use a window ENDING at the previous candle — the signal candle does not inflate its own threshold.
avgSpread  = ta.sma(spread, lenSpread)[1]
avgDensity = ta.sma(density, lenDensity)[1]

isNewLow  = low <= ta.lowest(low, lenExtreme)[1]
isNewHigh = high >= ta.highest(high, lenExtreme)[1]

densityOK = density >= densityFactor * avgDensity
spreadOK  = not useSpread or spread <= spreadFactor * avgSpread

// Close position within the candle range (0–100); a zero-range candle passes the filter in both directions
posFromLow  = spread > 0 ? (close - low) / spread * 100 : 100
posFromHigh = spread > 0 ? (high - close) / spread * 100 : 100

// On historical candles barstate.isconfirmed is always true — the option only affects the live candle.
confirmedOK = not onlyConfirmed or barstate.isconfirmed

accSignal  = confirmedOK and volume > 0 and isNewLow and densityOK and spreadOK and posFromLow >= closePct
distSignal = confirmedOK and volume > 0 and isNewHigh and densityOK and spreadOK and posFromHigh >= closePct

// Markers as plotshapes — shape, position, and color live in the Style tab, per signal.
plotshape(accSignal, 'Accumulation', style=shape.triangleup, location=location.belowbar, color=color.rgb(74, 136, 250), size=size.small)
plotshape(distSignal, 'Distribution', style=shape.triangledown, location=location.abovebar, color=color.rgb(215, 125, 95), size=size.small)

alertcondition(accSignal, 'Accumulation density', 'Accumulation density — potential bullish signal (heavy volume with little movement at a new low)')
alertcondition(distSignal, 'Distribution density', 'Distribution density — potential bearish signal (heavy volume with little movement at a new high)')

// Hidden signal series (+1 accumulation, -1 distribution, 0 none) — lets other scripts
// use this indicator as an external source (input.source) and shows up in the Data Window.
plot(accSignal ? 1 : distSignal ? -1 : 0, 'Signal', display=display.data_window, editable=false)

// Warn when the symbol has no volume data at all — the indicator can never signal there.
cumVolume = ta.cum(nz(volume))
if barstate.islast and cumVolume == 0
    var table warn = table.new(position.top_right, 1, 1)
    table.cell(warn, 0, 0, 'No volume data on this symbol - the indicator cannot signal', text_color=color.white, bgcolor=color.new(color.red, 15), text_size=size.small)

Overview

Accumulation / Distribution Density (VD) measures density as volume divided by candle range and flags bars whose density is well above a prior average and that set a local low or high. A marker below the bar marks accumulation and a marker above marks distribution. Settings control extreme lookback, average spread and density windows, spread and density factors, and how far the close sits inside the range. By default it signals only on closed candles.

Details

Published by

piecioshka on GitHub

Type

Indicator, Pine Script v6

Draws

On the price 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
Max/Min of (bars)int5lenExtreme
Average Spread of (bars)int5lenSpread
Average Density of (bars)int5lenDensity
Spread conditionbooltrueuseSpread
Spread Factorfloat1.4spreadFactor
Density Factorfloat2densityFactor
Bar close (%)int0closePct
Signal on closed candle onlybooltrueonlyConfirmed
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

Calculates an Elastic Volume Weighted Moving Average (EVWMA), incorporating trading volume to dynamically adjust moving average responsiveness over a specified lookback length. It plots directly on the price chart as a single moving average line. Optional colo

Indicator v4 Moving averagesVolume
Updated 10 days ago · GPL-3.0 GitHub repository of Elastic Volume Weighted Moving Average

This overlay indicator screens a pasted list of up to forty symbols and draws a table on the price chart. It classifies bullish or bearish setups from the percent change between the current candle and the candle 250 bars back, then shows RSI with a simple movi

Indicator v5 Oscillators & momentumVolume
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup - Ankush Bajaj Momentum Investing Setup

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

Indicator v5 VolumeSupport & resistance
Updated 2 months ago · MIT GitHub repository of Volume Profile and Indicator by DGT

META-tracker

by Allen1212
303 stars

This indicator overlays historical ARK Invest buy and sell events for META on the price chart. It places green labels below bars for purchases and red labels above bars for sales, with a same-day count of how many selected ARK ETFs traded the stock. The ETF in

Indicator v4 Volume
Updated 2 years ago · None stated GitHub repository of META-tracker
219 stars

An educational Pine Script v4 indicator demonstrating how to plot volume histograms on the main price chart using unscaled axes. The code includes examples and commented templates for creating vertical line markers at specific dates or time zones, such as mark

Indicator v4 Sessions & timeVolume
Updated 5 years ago · None stated GitHub repository of 教學-畫垂直線1

More indicators

Trade Your Charts With a Regulated Broker

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

Compare brokers