Examples
Cumulative delta as candles
The cumulative delta of the session drawn as candles in its own pane: each candle opens at the previous close of the cumulative delta and moves by the bar's delta, with the bar's intrabar delta extremes as wicks when they are known.
indicator "CVD candles" { overlay: false, format: "compact", labels: true }
reset = input.choice("Reset", ["session", "rth", "day", "none"], "session")
cvd = of.cvd(reset: reset)
prevCvd = cvd - nz(delta)
hi = na(bar.delta_high) ? max(prevCvd, cvd) : prevCvd + bar.delta_high
lo = na(bar.delta_low) ? min(prevCvd, cvd) : prevCvd + bar.delta_low
candle(prevCvd, hi, lo, cvd, cvd >= prevCvd ? #26a69a : #ef5350)
hline(0, color: #888888, style: "dotted")What to notice:
of.cvd(reset:)resets at the chosen boundary;prevCvdis the value before this bar's delta;bar.delta_high/bar.delta_loware the running-delta extremes inside the bar, ornawhen the source does not provide them, hence the fallback.