Indicator · Pine Script v4 · Own pane

Cumulative Delta Volume

by theonetrade· code credited to LonesomeTheBlue

Cumulative Delta Volume calculates an estimated cumulative buy and sell volume delta based on candle wick and body proportions.

View on GitHub

GitHub stars34on the repository
Pine versionv4older, still runs
Lines of code75
Settings20inputs
LicenceMIT
Last update2 weeks ago8 Nov 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

75 lines of Pine Script v4 from assets/indicator/bit-exact/cumulative_delta_volume_vB1T3EMp.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

cumulative_delta_volume_vB1T3EMp.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © LonesomeTheBlue
 
//@version=4
study("Cumulative Delta Volume", "CDV")
linestyle = input(defval = 'Candle', title = "Style", options = ['Candle', 'Line'])
hacandle = input(defval = true, title = "Heikin Ashi Candles?")
showma1 = input(defval = false, title = "SMA 1", inline = "ma1")
ma1len = input(defval = 50, title = "", minval = 1, inline = "ma1")
ma1col = input(defval = color.lime, title = "", inline = "ma1")
showma2 = input(defval = false, title = "SMA 2", inline = "ma2")
ma2len = input(defval = 200, title = "", minval = 1, inline = "ma2")
ma2col = input(defval = color.red, title = "", inline = "ma2")
showema1 = input(defval = false, title = "EMA 1", inline = "ema1")
ema1len = input(defval = 50, title = "", minval = 1, inline = "ema1")
ema1col = input(defval = color.lime, title = "", inline = "ema1")
showema2 = input(defval = false, title = "EMA 2", inline = "ema2")
ema2len = input(defval = 200, title = "", minval = 1, inline = "ema2")
ema2col = input(defval = color.red, title = "", inline = "ema2")
colorup = input(defval = color.lime, title = "Body", inline = "bcol")
colordown = input(defval = color.red, title = "", inline = "bcol")
bcolup = input(defval = #74e05e, title = "Border", inline = "bocol")
bcoldown = input(defval = #ffad7d, title = "", inline = "bocol")
wcolup = input(defval = #b5b5b8, title = "Wicks", inline = "wcol")
wcoldown = input(defval = #b5b5b8, title = "", inline = "wcol")

tw = high - max(open, close) 
bw = min(open, close) - low 
body = abs(close - open) 

_rate(cond) =>
    ret = 0.5 * (tw + bw + (cond ? 2 * body : 0)) / (tw + bw + body) 
    ret := nz(ret) == 0 ? 0.5 : ret
    ret
    
deltaup =  volume * _rate(open <= close) 
deltadown = volume * _rate(open > close)
delta = close >= open ? deltaup : -deltadown
cumdelta = cum(delta)
float ctl = na
float o = na
float h = na
float l = na
float c = na
if linestyle == 'Candle'
    o := cumdelta[1]
    h := max(cumdelta, cumdelta[1])
    l := min(cumdelta, cumdelta[1])
    c := cumdelta
    ctl
else
    ctl := cumdelta

plot(ctl, title = "CDV Line", color = color.blue, linewidth = 2)

float haclose = na
float haopen = na
float hahigh = na
float halow = na
haclose := (o + h + l + c) / 4
haopen  := na(haopen[1]) ? (o + c) / 2 : (haopen[1] + haclose[1]) / 2
hahigh  := max(h, max(haopen, haclose))
halow   := min(l,  min(haopen, haclose))
 
c_ = hacandle ? haclose : c
o_ = hacandle ? haopen : o
h_ = hacandle ? hahigh : h
l_ = hacandle ? halow : l

plotcandle(o_, h_, l_, c_, title='CDV Candles', color = o_ <= c_ ? colorup : colordown, bordercolor = o_ <= c_ ? bcolup : bcoldown, wickcolor = o_ <= c_ ? bcolup : bcoldown)

plot(showma1 and linestyle == "Candle" ? sma(c_, ma1len) : na, title = "SMA 1", color = ma1col)
plot(showma2 and linestyle == "Candle"  ? sma(c_, ma2len) : na, title = "SMA 2", color = ma2col)
plot(showema1 and linestyle == "Candle"  ? ema(c_, ema1len) : na, title = "EMA 1", color = ema1col)
plot(showema2 and linestyle == "Candle"  ? ema(c_, ema2len) : na, title = "EMA 2", color = ema2col)

Overview

Cumulative Delta Volume aggregates volume bar by bar to track directional buying and selling pressure over time. The indicator plots in a separate pane as either a continuous line or full candlesticks, with an optional Heikin Ashi transformation. Users can enable and configure up to two simple moving averages and two exponential moving averages overlaying the calculated delta series.

Details

Published by

theonetrade on GitHub

Code credit

LonesomeTheBlue, as written in the script's header

Type

Indicator, Pine Script v4

Draws

Separate pane below the chart

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

algorithmic-tradingbacktestingbitcoinccxtcrypto-tradingllm-agentoffline-backtestingopen-source-tradingpine-scriptpine-to-pythonpinescriptpynecorepythonquantquantitative-financestrategy-backtestingtechnical-analysistrading-indicatorstrading-strategiestradingview

Settings

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

SettingTypeDefaultVariable
StylestringCandlelinestyle
Heikin Ashi Candles?booltruehacandle
SMA 1boolfalseshowma1
ma1lenint50ma1len
ma1colcolorcolor.limema1col
SMA 2boolfalseshowma2
ma2lenint200ma2len
ma2colcolorcolor.redma2col
EMA 1boolfalseshowema1
ema1lenint50ema1len
ema1colcolorcolor.limeema1col
EMA 2boolfalseshowema2
Show all 20 settings
SettingTypeDefaultVariable
ema2lenint200ema2len
ema2colcolorcolor.redema2col
Bodycolorcolor.limecolorup
colordowncolorcolor.redcolordown
Bordercolor#74e05ebcolup
bcoldowncolor#ffad7dbcoldown
Wickscolor#b5b5b8wcolup
wcoldowncolor#b5b5b8wcoldown
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

4 stars

This indicator recolors price candles from recent volume and range. It marks climax bars when current volume times range exceeds the prior ten-bar peak or volume is at least twice a ten-bar average, and rising bars at one and a half times that average. Bullish

Indicator v5 VolumeCandlestick patterns
Updated 10 months ago · None stated GitHub repository of Price-Volume Analysis

VGF Price-Volume TEMA

by ryangaraygay
2 stars

This indicator colors chart bars based on a Triple Exponential Moving Average (TEMA) applied to candle body volume (candle body multiplied by volume). It categorizes market flow into trending bullish, trending bearish, or non-trending messy conditions based on

Indicator v5 VolumeCandlestick patterns
Updated 1 year ago · MIT GitHub repository of VGF Price-Volume TEMA

VWAP and VWMA

by Web3Degenerate
2 stars

This indicator plots either a Volume Weighted Average Price (VWAP) or a Volume Weighted Moving Average (VWMA) directly on the price chart, coloring the line based on whether the close is above or below it. It generates trading signals by combining the trend fi

Indicator v5 Moving averagesCandlestick patterns
Updated 2 years ago · None stated GitHub repository of VWAP and VWMA

蜡烛图形态

by fuyuanyuan
1 stars

This overlay indicator classifies candlestick shapes using body, wick, and range sizes, then filters them with volume, RSI, MACD, and exponential moving averages. A hammer needs a long lower wick, a small bearish body, RSI below 30, and elevated prior volume.

Indicator v6 Candlestick patternsOscillators & momentum
Updated 1 year ago · None stated GitHub repository of 蜡烛图形态

[TVT] OBV with EMA

by namuan
321 stars

Calculates On-Balance Volume (OBV) alongside two Exponential Moving Averages (EMAs) applied directly to the cumulative OBV line. The indicator tracks volume flow relative to price movement and smooths it using short-term and longer-term EMAs to highlight volum

Indicator v6 VolumeOscillators & momentum
Updated 8 days ago · MIT GitHub repository of [TVT] OBV with EMA

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

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