The obv idea with a finer signal. OBV counts a bar's whole volume
as buying or selling on the sign of the close change alone; A/D grades it
by the close's position in the bar, so a bar that rallies and gives it all
back contributes little in either direction. Like OBV the level is
arbitrary — the line is read for its slope and for divergence against
price — so this study has no period: there is nothing to size a
window over.
Appends one column, defined from the first bar: A/D's term needs only
the bar itself (no previous close), so unlike OBV there is not even a
seeding convention to pick.
Both halves live in kernels — clvValues derives the per-bar
location, cumulativeValues accumulates — and the composed
accumulationDistributionValues is what chaikinOscillator
smooths, so the two studies read one array rather than two derivations.
Four inputs
High, low, close and volume, each named by an option defaulting to its
DEFAULT_OHLCV name — the atr rule, applied once more.
Definition, verified
TA-Lib's AD, exactly on gap-free bars with a range: cross-checked
bar-for-bar in the oracle fixture (delta 0, and an identical — empty —
warm-up mask). No period, so there is one case rather than two.
Edges — the running-sum rules
A leading gap in any input shifts the seed to the first bar where
all four are present, which is what lets the line run over another
study's output rather than come back empty (obv's rule).
An interior gap propagates to the end. Every level after an unknown
term is unknown; skipping it would report a level silently off by the
missing contribution for the rest of the series. Fill before running if
you need continuity.
A flat bar (high === low) contributes 0 and the line carries on —
the close location's numerator is exactly zero there, so this is the
value, not a convention (clvValues). It is also what TA-Lib's
AD does (measured on twelve bars with bar 3 flattened: [0, 100, 100, 100, 100, 400, …, 1900]), so the two agree on every bar, halts
included. Only a missing price is a gap.
Scale behaviour: linear in volume, and invariant under any affine
change of price — scaling or shifting every price leaves the close
location, and so the line, unchanged. Both pinned by property tests.
Accumulation/Distribution line (Marc Chaikin) — a running total of each bar's volume signed by where in its own range it closed:
The obv idea with a finer signal. OBV counts a bar's whole volume as buying or selling on the sign of the close change alone; A/D grades it by the close's position in the bar, so a bar that rallies and gives it all back contributes little in either direction. Like OBV the level is arbitrary — the line is read for its slope and for divergence against price — so this study has no
period: there is nothing to size a window over.Appends one column, defined from the first bar: A/D's term needs only the bar itself (no previous close), so unlike OBV there is not even a seeding convention to pick.
Both halves live in kernels — clvValues derives the per-bar location, cumulativeValues accumulates — and the composed accumulationDistributionValues is what chaikinOscillator smooths, so the two studies read one array rather than two derivations.
Four inputs
High, low, close and volume, each named by an option defaulting to its
DEFAULT_OHLCVname — the atr rule, applied once more.Definition, verified
TA-Lib's
AD, exactly on gap-free bars with a range: cross-checked bar-for-bar in the oracle fixture (delta0, and an identical — empty — warm-up mask). Noperiod, so there is one case rather than two.Edges — the running-sum rules
high === low) contributes0and the line carries on — the close location's numerator is exactly zero there, so this is the value, not a convention (clvValues). It is also what TA-Lib'sADdoes (measured on twelve bars with bar 3 flattened:[0, 100, 100, 100, 100, 400, …, 1900]), so the two agree on every bar, halts included. Only a missing price is a gap.