# Change-point Detection

Also known as: CUSUM.
A Statistics concept (Complexity & memory) in the LuxAlgo Library, with 1 indicator implementation.

## What is Change-point Detection?

Change-point detection is the statistical problem of locating when a time series' generating process shifted: a change in mean, in variance, or in distribution, as opposed to where price is heading next. The classic sequential detector is CUSUM (Page, 1954), built for industrial quality control. It maintains running sums of deviations above and below a reference level, subtracts a small slack allowance each bar so pure noise decays back toward zero, and raises an alarm when an accumulated sum crosses a decision threshold. Because evidence accumulates, a persistent small drift eventually trips the detector even when no single bar looks unusual.

CUSUM is one member of a larger family. Offline methods segment a completed history into regimes after the fact, which suits research and backtest hygiene; online methods like CUSUM and Bayesian change-point detectors update bar by bar and are the ones that can run on a live chart. All of them formalize the same question a discretionary trader asks loosely: does recent data still look like it came from the same market as before?

Applied to returns, an alarm marks a candidate shift in drift (a trend starting or dying); applied to squared or absolute returns, it flags [volatility regime switches](https://www.luxalgo.com/library/concept/volatility-regime-switches/). The tuning is an explicit trade-off: tighter thresholds detect changes sooner but fire more false alarms, looser ones are quieter but slower. Detection is also inherently after the fact, since a change must accumulate evidence before it becomes visible, which is why change points pair naturally with persistence gauges like the [Hurst exponent](https://www.luxalgo.com/library/concept/hurst-exponent/) rather than acting as standalone entries.

The reason the idea earns chart space is that almost every indicator assumes the recent past is representative. A [Z-score](https://www.luxalgo.com/library/concept/z-score/) needs a stable mean and deviation, a [percentile rank](https://www.luxalgo.com/library/concept/percentile-rank/) needs a comparable history, and any [distribution-of-returns profile](https://www.luxalgo.com/library/concept/distribution-of-returns-profiling/) blends regimes if the window spans a break. A detected change point says where representativeness ended, which is often more valuable than any single forecast.

## How to read a change-point detector on a chart

The detector plots as an auxiliary series with alarms; reading it is about knowing what was fed in and how sensitive it is.

1. Check the input series first: detectors run on returns flag drift changes, while those on squared or absolute returns flag volatility shifts; the alarm means nothing without knowing which.
2. Note the tuning: the reference level, the slack allowance, and the alarm threshold jointly set how fast it reacts and how often it cries wolf.
3. Watch the cumulative sums build: a one-sided sum grinding away from zero shows evidence accumulating even before any alarm prints.
4. Treat the alarm bar as a timestamp, not a signal: it says the recent stretch no longer resembles the reference regime, and the sums typically restart from there.
5. Cross-check the flagged date against the chart and other regime reads, such as an [autocorrelation](https://www.luxalgo.com/library/concept/autocorrelation/) shift or a volatility break, before changing behavior.

## How traders use it

- As a regime alarm: CUSUM on returns timestamps candidate shifts in drift, prompting a re-read of structure and bias or an update to a [trend regime label](https://www.luxalgo.com/library/concept/trend-regime-label/), rather than triggering trades by itself.
- As a volatility monitor: run on squared or absolute returns to flag transitions between quiet and turbulent conditions that sizing and stop rules should respond to.
- As an adaptive anchor: restart lookbacks, distributions, or averages from the most recent detected change point so statistics describe only the current regime instead of blending regimes.
- As backtest hygiene: segmenting a history at detected change points keeps parameter fits and [distribution profiles](https://www.luxalgo.com/library/concept/distribution-of-returns-profiling/) from being estimated across regime boundaries, and shows how a rule behaves regime by regime.
- As a normalization guard: recomputing [Z-scores](https://www.luxalgo.com/library/concept/z-score/) or [percentile ranks](https://www.luxalgo.com/library/concept/percentile-rank/) from the last change point instead of a fixed window keeps those readings from mixing the old regime's scale into the new one.

## Change-point Detection vs related statistics

- **Z-score** (https://www.luxalgo.com/library/concept/z-score/): A Z-score says how unusual the latest value is under the assumption the regime is stable. Change-point detection questions that assumption, accumulating evidence that the mean or spread itself has moved. One grades a data point; the other grades the process.
- **Autocorrelation** (https://www.luxalgo.com/library/concept/autocorrelation/): Autocorrelation describes a regime's internal texture, how strongly returns echo their own past, and it needs a stable window to mean anything. A change point marks where such descriptions stop applying, so the two are naturally chained: segment first, then characterize.
- **Distribution-of-returns Profiling** (https://www.luxalgo.com/library/concept/distribution-of-returns-profiling/): Profiling summarizes the shape of returns over a window: tails, skew, dispersion. Run across a regime break it averages two different markets into one misleading picture, which is exactly the failure change-point detection exists to prevent.

## FAQ

### What is CUSUM and how is it used in trading?

CUSUM (cumulative sum) is a sequential control-chart method from quality engineering, introduced by E. S. Page in 1954. It accumulates deviations of a series from a reference level, decaying them with a slack term, and signals when the running sum exceeds a threshold. Traders apply it to returns or volatility proxies to flag regime shifts more systematically than visual inspection allows.

### Can change-point detection predict regime changes in advance?

No. It detects changes after enough evidence has accumulated, so there is always some lag between the true shift and the alarm. Sensitivity settings only trade that lag against false alarms: react faster and you accept more noise-triggered alerts. The practical role is hypothesis generation, flagging that recent data no longer looks like the old regime so positioning assumptions get reviewed.

### Should the detector run on prices or returns?

Returns, almost always. Prices trend by nature, so a detector pointed at raw prices alarms constantly on ordinary drift. Differencing to returns (or log returns) makes the stable-regime assumption meaningful: a mean shift in returns is a genuine drift change, and a variance shift is a genuine volatility change. Squared or absolute returns are the standard volatility proxies.

### How do you set CUSUM's slack and threshold?

They encode the change size you care about and the false-alarm rate you can tolerate. The slack is often set near half the smallest shift worth detecting, and the threshold then controls average time between false alarms; quality-control texts publish standard pairings. In markets there is no universal constant, so practitioners calibrate on historical data and err toward fewer, later alarms.

### What is the difference between online and offline change-point detection?

Online detectors process data as it arrives and can only use the past, so they suit live monitoring and accept detection lag. Offline methods see the whole series at once and place change points with hindsight, which makes them better for research, segmentation, and backtest construction but useless as live signals. Confusing the two is a common source of look-ahead bias in tested strategies.

### Do change-point alarms repaint?

A proper online detector does not: once an alarm prints on a bar, it stays there, because it used only information available at the time. Offline segmentations, by contrast, can move historical change points every time they are re-run on more data. If a charting implementation shows change points shifting as new bars arrive, it is doing offline analysis in a live costume.

## Implementations in the Library

- Change-Point Detection (CUSUM) (LuxAlgo): https://www.luxalgo.com/library/indicator/change-point-detection-cusum/

## Related concepts

- Hurst Exponent: https://www.luxalgo.com/library/concept/hurst-exponent/
- Fractal Dimension: https://www.luxalgo.com/library/concept/fractal-dimension/
- Entropy Measures: https://www.luxalgo.com/library/concept/entropy-measures/
- Market Efficiency & Regime Persistence Measures: https://www.luxalgo.com/library/concept/market-efficiency-and-regime-persistence-measures/

---

Source: https://www.luxalgo.com/library/concept/change-point-detection/ (LuxAlgo Library, the encyclopedia of trading & technical analysis). Free to use with attribution: https://www.luxalgo.com/library/license/