Indicator · Pine Script v6 · Own pane

CVD Bias [WavesUnchained]

by casoon

This indicator plots a heuristic volume-balance oscillator in a separate pane.

View on GitHub

GitHub stars9on the repository
Pine versionv6current
Lines of code173
Settings8inputs
LicenceMIT
Last update3 days ago27 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

173 lines of Pine Script v6 from indicators/money_flow/cvd_bias/cvd_bias.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

cvd_bias.pine
//@version=6
// ============================================================================
// CVD Bias [WavesUnchained]
// Version: 1.1.5
// Author: WavesUnchained
// Build: 2026-10-12
// ============================================================================
// Estimates a price-weighted volume balance over a rolling window. This is
// NOT real Cumulative Volume Delta — OHLCV data carries no aggressor-side
// trade classification, so "buying" and "selling" volume are inferred only
// from where price closed within the bar's range, never from actual trade
// direction. Real Delta/CVD requires request.footprint() (out of scope
// here). Within that heuristic, the per-bar signed-volume proxy is
// accumulated as a running total rather than smoothed into an EMA, showing
// whether the price-weighted balance has been persistently skewed bullish or
// bearish and whether that skew is building or fading.
//
// Features:
//   ✓ Per-bar signed-volume proxy: (2 × close_location − 1) × volume (heuristic, not real CVD)
//   ✓ Rolling sum: accumulated over configurable window, normalized to −1..+1
//   ✓ Rate of change: acceleration of the volume-balance proxy
//   ✓ Price/proxy divergence: price new N-bar extreme while proxy rate opposes
//   ✓ Dashboard: proxy level, rate, divergence state
//   ✓ Alerts: bull/bear divergence, zero cross
//
// Data Contract:
//   Price:     REQUIRED   chart symbol
//   Volume:    REQUIRED   real trade volume — feed must deliver volume and
//                         syminfo.volumetype must not be "tick"; otherwise not available
//   OI:        NO
//   Reference: NO
//   Verdict:   Exchange-only
// ============================================================================

indicator("CVD Bias [WavesUnchained]", "CVD [WU]", format=format.price, precision=2, overlay=false)

// ─── Inputs ───────────────────────────────────────────────────────────────────

grCVD      = "CVD Settings"
cvdLen     = input.int(50,  "Accumulation Window",    minval=10, maxval=500,  group=grCVD,
     tooltip="Bars over which the signed-volume proxy is summed. Longer = smoother, slower to react.")
normLen    = input.int(200, "Normalization Lookback",  minval=20, maxval=1000, group=grCVD,
     tooltip="Lookback for finding recent CVD amplitude. Used to keep the oscillator on a −1..+1 scale.")
rocLen     = input.int(5,   "Rate of Change Length",  minval=1,  maxval=30,   group=grCVD)

grDiv      = "Divergence"
enableDiv  = input.bool(true, "Detect Price/CVD Divergences", group=grDiv)
pivLeft    = input.int(5, "Swing Left Bars", minval=1, group=grDiv)
pivRight   = input.int(5, "Swing Right Bars", minval=1, group=grDiv,
     tooltip="Lookback period for confirming a pivot high or low. Larger values reduce noise but increase signal delay.")

grD        = "Display"
showDash   = input.bool(true, "Show Dashboard", group=grD)

// Echtes Handelsvolumen? Nur "tick" schließt es ausdrücklich aus (Anzahl
// Transaktionen, keine Menge). "n/a" heißt laut Referenz "kein Volumen ODER Art
// nicht angegeben" — die meisten Feeds außer Krypto melden das, auch Futures mit
// echten Kontrakten. Dort entscheidet, ob der Feed überhaupt Volumen liefert.
var bool feedHasVolume = false
if nz(volume) > 0
    feedHasVolume := true
bool volumeIsReal = syminfo.volumetype != "tick" and feedHasVolume
float vol = volumeIsReal ? volume : na

// ─── Per-bar signed-volume proxy ──────────────────────────────────────────────
// closeLoc = 0: closed at low (full bear bar), 1: closed at high (full bull bar)
// signedVolumeProxy: price-location-weighted volume — a heuristic, NOT real
// trade delta. OHLCV has no aggressor-side classification.

hl                = high - low
closeLoc          = hl > 0 ? (close - low) / hl : 0.5
signedVolumeProxy = (2.0 * closeLoc - 1.0) * vol

// ─── Rolling CVD + normalization ─────────────────────────────────────────────

cvdRaw  = math.sum(signedVolumeProxy, cvdLen)
cvdAmp  = ta.highest(math.abs(cvdRaw), normLen)
cvdNorm = not volumeIsReal ? na : cvdAmp > 0 ? cvdRaw / cvdAmp : 0.0

// Rate of change: how fast is the balance shifting
cvdRoc = cvdNorm - nz(cvdNorm[rocLen])

// ─── Divergence: structural swing-pivot divergence ───────────────────────────
ph = ta.pivothigh(high, pivLeft, pivRight)
pl = ta.pivotlow(low,   pivLeft, pivRight)

prevPh = ta.valuewhen(not na(ph), high[pivRight], 1)
prevPl = ta.valuewhen(not na(pl), low[pivRight], 1)

prevCvdAtPh = ta.valuewhen(not na(ph), cvdNorm[pivRight], 1)
prevCvdAtPl = ta.valuewhen(not na(pl), cvdNorm[pivRight], 1)

bearDivRaw = not na(ph) and not na(prevPh) and high[pivRight] > prevPh and cvdNorm[pivRight] < prevCvdAtPh
bullDivRaw = not na(pl) and not na(prevPl) and low[pivRight] < prevPl and cvdNorm[pivRight] > prevCvdAtPl

bearDiv = enableDiv and bearDivRaw
bullDiv = enableDiv and bullDivRaw

// ─── Colors ───────────────────────────────────────────────────────────────────

bullC    = color.new(#00c853, 0)
bearC    = color.new(#d50000, 0)
neutC    = color.new(color.gray, 30)
cvdColor = cvdNorm > 0.2 ? bullC : cvdNorm < -0.2 ? bearC : neutC
rocColor = cvdRoc >= 0 ? color.new(#00c853, 40) : color.new(#d50000, 40)

// ─── Plots ────────────────────────────────────────────────────────────────────

hline(0,    "Zero",      color=color.new(color.gray, 50))
hline(0.5,  "Bull Zone", color=color.new(#00c853, 70), linestyle=hline.style_dotted)
hline(-0.5, "Bear Zone", color=color.new(#d50000, 70), linestyle=hline.style_dotted)

plot(cvdNorm, "CVD Bias", color=cvdColor, linewidth=2)
plot(cvdRoc,  "CVD Rate", color=rocColor, linewidth=1)

plotshape(bearDiv, "Bear Div", shape.triangledown, location.top,    color=bearC, size=size.small, offset=-pivRight)
plotshape(bullDiv, "Bull Div", shape.triangleup,   location.bottom, color=bullC, size=size.small, offset=-pivRight)

// ─── Dashboard ────────────────────────────────────────────────────────────────

color tc = color.new(color.gray, 20)
color hd = color.new(color.gray, 90)

var table t = table.new(position.top_right, 2, 5,
     bgcolor=color.new(color.white, 5),
     border_color=color.new(color.gray, 60), border_width=1,
     frame_color=color.new(color.gray, 40), frame_width=1)

if showDash and barstate.islast and volumeIsReal
    table.cell(t, 0, 0, "CVD Bias",   text_color=tc, bgcolor=hd, text_size=size.small)
    table.cell(t, 1, 0, "Value",      text_color=tc, bgcolor=hd, text_size=size.small)

    string cvdState = "Neutral"
    if cvdNorm > 0.5
        cvdState := "Strong Bull"
    else if cvdNorm > 0.2
        cvdState := "Bull"
    else if cvdNorm < -0.5
        cvdState := "Strong Bear"
    else if cvdNorm < -0.2
        cvdState := "Bear"
    cvdC = cvdNorm > 0.2 ? bullC : cvdNorm < -0.2 ? bearC : tc

    table.cell(t, 0, 1, "State",      text_color=tc,   text_size=size.small)
    table.cell(t, 1, 1, cvdState,     text_color=cvdC, text_size=size.small)
    table.cell(t, 0, 2, "CVD",        text_color=tc,   text_size=size.small)
    table.cell(t, 1, 2, str.tostring(cvdNorm, "#.##"), text_color=cvdC, text_size=size.small)

    rocStr = cvdRoc >= 0 ? "Rising ↑" : "Falling ↓"
    rocC2  = cvdRoc >= 0 ? bullC : bearC
    table.cell(t, 0, 3, "Rate",       text_color=tc,    text_size=size.small)
    table.cell(t, 1, 3, rocStr,       text_color=rocC2, text_size=size.small)

    divState = bearDiv ? "Bear Div!" : bullDiv ? "Bull Div!" : "—"
    divC     = bearDiv ? bearC : bullDiv ? bullC : tc
    table.cell(t, 0, 4, "Divergence", text_color=tc,   text_size=size.small)
    table.cell(t, 1, 4, divState,     text_color=divC, text_size=size.small)

// Kurzer Hinweis unten rechts; was fehlt, steht im Data Contract oben.
var table volWarn = table.new(position.bottom_right, 1, 1)
if barstate.islast and not volumeIsReal
    table.cell(volWarn, 0, 0, "CVD · not available",
         bgcolor = color.new(color.orange, 20), text_color = color.white, text_size = size.small)

// ─── Alerts ───────────────────────────────────────────────────────────────────

bool alertsOnBarClose = input.bool(true, "Alerts only on bar close (confirmed)", group="Alerts")
bool alertOk = not alertsOnBarClose or barstate.isconfirmed

alertcondition(alertOk and (bullDiv), "CVD Bull Divergence", "CVDB · BULL CVD DIV · {{ticker}} {{interval}}")
alertcondition(alertOk and (bearDiv), "CVD Bear Divergence", "CVDB · BEAR CVD DIV · {{ticker}} {{interval}}")
alertcondition(alertOk and (ta.crossover(cvdNorm, 0)),  "CVD Cross Up",   "CVDB · CROSS UP · {{ticker}} {{interval}}")
alertcondition(alertOk and (ta.crossunder(cvdNorm, 0)), "CVD Cross Down", "CVDB · CROSS DOWN · {{ticker}} {{interval}}")

Overview

CVD Bias [WavesUnchained] estimates signed volume from the close location inside each bar, multiplies that by volume, and sums the proxy over a rolling window. The sum is scaled between minus one and plus one, and a rate-of-change line shows whether the skew is building or fading. Optional pivots mark price extremes that oppose the proxy rate. A dashboard reports level, rate, and divergence, and alerts can wait until the bar closes. It requires real trade volume rather than tick counts or aggressor-side data.

Details

Published by

casoon on GitHub

Draws

Separate pane below the chart

Markets

Crypto, Stocks, Indices, Oil & commodities

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

pine-scriptpinescripttechnical-analysistrading-indicatorstrading-strategiestradingview

Settings

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

SettingTypeDefaultVariable
Accumulation Windowint50cvdLen
Normalization Lookbackint200normLen
Rate of Change Lengthint5rocLen
Detect Price/CVD DivergencesbooltrueenableDiv
Swing Left Barsint5pivLeft
Swing Right Barsint5pivRight
Show DashboardbooltrueshowDash
Alerts only on bar close (confirmed)booltruealertsOnBarClose
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

Oscillator Suite

by TamaraKGreen
46 stars

Oscillator Suite plots a normalised price oscillator in a separate pane and overlays a signal line that can use SMA, EMA, WMA, HMA, RMA, VWMA, T3, ZEMA, KAMA, or GKEMA. It marks bullish and bearish divergences, a smoothed money-flow series, confluence areas an

Indicator v5 Oscillators & momentumDivergence
Updated 8 weeks ago · None stated GitHub repository of Oscillator Suite
11 stars

This indicator plots a smoothed Z-score of cumulative volume delta in a separate pane, showing whether buying or selling pressure is dominant and when the reading enters extreme zones. It marks spot accumulation, climax or exhaustion, and pivot-based price-vol

Indicator v6 Oscillators & momentumVolume Repaints
Updated 7 weeks ago · MIT GitHub repository of CVD Z-Score [NeuNue]

Apex Vector

by app-builder-sketch
1 stars

Apex Vector is a separate-pane oscillator that plots a smoothed vector and classifies efficiency against superconductor and resistive thresholds, with a high-heat warning color. Optional volume flux uses a volume-normalization length. Users set vector length,

Indicator v6 Oscillators & momentumVolume
Updated 10 months ago · GPL-3.0 GitHub repository of Apex Vector

This indicator scans a pasted list of symbols for RSI directional momentum and shows matching long and short signals in a table in a separate pane. The user chooses continuous break, continuous retracement, flip break, flip retracement, divergence, or hidden d

Indicator v6 Oscillators & momentumDivergence
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup - RSI Directional Momentum Scanner
228 stars

This indicator calculates the Relative Strength Index (RSI) across four user-selected timeframes and plots the results in a separate pane. It identifies regular bullish and bearish divergences between price pivot points and the primary timeframe RSI value. Add

Indicator v6 Oscillators & momentumDivergence
Updated 3 months ago · None stated GitHub repository of Multi-Timeframe RSI with Divergence

MFI Divergences

by tistaharahap
25 stars

This indicator plots the Money Flow Index in a separate pane and marks regular and hidden bullish and bearish divergences between price pivots and the oscillator. It builds the index from positive and negative money flow, then finds pivot highs and lows using

Indicator v4 Oscillators & momentumVolume
Updated 6 years ago · None stated GitHub repository of MFI Divergences

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