where ROC(n) is the percent change over n bars,
(x[i]/x[i−n] − 1) × 100 — the same percentChange the package
already ships (and the same TA-Lib ROC). Appends one column.
The monthly convention — and why the periods are still bar counts
Coppock's defaults are months: 14- and 11-month rates of change,
smoothed by a 10-month weighted average, on a monthly index chart.
The lengths are not arbitrary — he took 11 and 14 from an estimate of the
average bereavement period, the analogy being how long a market takes to
recover from a loss — and the curve is read one way only: a cross up
through zero from below as a long-term buy signal, roughly once a
market cycle.
The study is nonetheless bar-count like every other in this package,
so coppock() on daily bars is a 14-day / 11-day / 10-day curve —
a defensible short-horizon oscillator, but not the indicator Coppock
defined and not one his thresholds apply to. Run it on monthly bars (or
on aggregate output at a monthly grain) to get his. Stated here because
the defaults look innocuous on any chart and quietly mean something else
on a daily one.
Definition notes
No TA-Lib function exists, so the oracle is a pandas replication —
on the same pct_change and linear-weight helpers used for the
TA-Lib-verified percentChange and wma, with the analytic first valid
bar asserted.
The average is a WMA, and that is part of the definition (linear
weights 1…wmaPeriod, newest heaviest), not a maType knob. Published
Coppock is the weighted average; an EMA-smoothed variant is a different
curve. If a caller wants one, movingAverage over this study's inputs
composes it — a knob here would let "the Coppock Curve" name two
different lines.
longPeriod and shortPeriod are symmetric — the two rates of
change are added, so swapping them changes nothing, and no ordering is
enforced. (Contrast macd, which rejects fastPeriod >= slowPeriod because its two spans are subtracted and the sign of the
result depends on which is which.)
Warm-up and edges
First value at max(longPeriod, shortPeriod) + wmaPeriod − 1 — bar
23 at the defaults. The sum is defined from bar longPeriod (the later
of the two look-backs), and the WMA then waits for wmaPeriod finite
values: a positional weight cannot skip a cell without reweighting the
rest, so it masks a short window rather than averaging what it has.
Scale-invariant. Both terms are ratios, so multiplying every bar by
a positive constant leaves the curve unchanged — pinned as a property
test. The output is in percent, and is unbounded either way.
A zero base → undefined for that rate of change, and the sum and
the windows containing it with it. Unreachable on prices; reachable
when column is a study output that crosses zero.
A leading gap shifts the start (the WMA waits for finite values); an
interior gap blanks the bar, the bar longPeriod/shortPeriod
later, and every window containing either — then recovers, the wma
rule.
Coppock Curve (Edwin Sedgwick Coppock, Barron's, 1962) — a linearly weighted average of two rates of change added together:
where
ROC(n)is the percent change overnbars,(x[i]/x[i−n] − 1) × 100— the same percentChange the package already ships (and the same TA-LibROC). Appends one column.The monthly convention — and why the periods are still bar counts
Coppock's defaults are months: 14- and 11-month rates of change, smoothed by a 10-month weighted average, on a monthly index chart. The lengths are not arbitrary — he took 11 and 14 from an estimate of the average bereavement period, the analogy being how long a market takes to recover from a loss — and the curve is read one way only: a cross up through zero from below as a long-term buy signal, roughly once a market cycle.
The study is nonetheless bar-count like every other in this package, so
coppock()on daily bars is a 14-day / 11-day / 10-day curve — a defensible short-horizon oscillator, but not the indicator Coppock defined and not one his thresholds apply to. Run it on monthly bars (or onaggregateoutput at a monthly grain) to get his. Stated here because the defaults look innocuous on any chart and quietly mean something else on a daily one.Definition notes
pct_changeand linear-weight helpers used for the TA-Lib-verifiedpercentChangeandwma, with the analytic first valid bar asserted.1…wmaPeriod, newest heaviest), not amaTypeknob. Published Coppock is the weighted average; an EMA-smoothed variant is a different curve. If a caller wants one,movingAverageover this study's inputs composes it — a knob here would let "the Coppock Curve" name two different lines.longPeriodandshortPeriodare symmetric — the two rates of change are added, so swapping them changes nothing, and no ordering is enforced. (Contrast macd, which rejectsfastPeriod >= slowPeriodbecause its two spans are subtracted and the sign of the result depends on which is which.)Warm-up and edges
max(longPeriod, shortPeriod) + wmaPeriod − 1— bar 23 at the defaults. The sum is defined from barlongPeriod(the later of the two look-backs), and the WMA then waits forwmaPeriodfinite values: a positional weight cannot skip a cell without reweighting the rest, so it masks a short window rather than averaging what it has.undefinedfor that rate of change, and the sum and the windows containing it with it. Unreachable on prices; reachable whencolumnis a study output that crosses zero.longPeriod/shortPeriodlater, and every window containing either — then recovers, thewmarule.