CUSUM Drift Trend [QuantAlgo]

4 135

More exclusive indicators from QuantAlgo

Subscribe to QuantAlgo Essential for $49.99/month to get exclusive indicators by this author. You pay right on TradingView and can use them on your charts straight away.

Explore QuantAlgo Essential
🟢 Overview

The CUSUM Drift Trend is a trend-following indicator that applies the cumulative sum (CUSUM) method from statistical quality control to price, confirming a trend change once volatility-scaled evidence against the prevailing direction accumulates past a decision threshold, whether that evidence arrives as one decisive move or as a persistent drift across many bars. It standardizes every bar’s price change by recent volatility, tallies upside and downside drift in two cumulative sums that discount minor noise, and plots a boundary at the level the next bar must close beyond to confirm a reversal, so traders can follow trends against a clearly defined invalidation level across every timeframe and market.
Snapshot
🟢 How It Works

The indicator is built around the cumulative sum test, a sequential change detection method introduced by E. S. Page in 1954 to flag when a production process drifts away from its target. Instead of judging each reading on its own, it keeps a running tally of deviations, so small departures that persist add up to a clear signal while random noise drains away. It has three stages: volatility scaling that expresses each bar’s price change in volatility units, two cumulative sums that collect upside and downside evidence, and a state engine that confirms trend changes when the opposing sum crosses the decision threshold.

First, each bar’s price change is scaled by volatility. The engine keeps an exponentially weighted estimate of the typical squared bar-to-bar change, with its span set by the volatility length, and divides the current change by the volatility measured before that bar, so a sudden shock is not diluted by its own size. Close is the default source, while averaged sources such as HL2 or HLC3 soften the effect of individual closing prints. The estimate starts as an equal-weighted average before the exponential weighting takes over, and the cumulative sums stay inactive until a full volatility length of changes has been observed:
Pine Script®

Next, the evidence is accumulated. The upside sum adds each standardized move minus the drift allowance, the downside sum adds each standardized decline minus the same allowance, and both are floored at zero. Moves smaller than the allowance drain a sum rather than build it, so choppy, directionless action tends to keep both tallies close to zero, while a persistent drift builds its sum bar after bar and a single outsized move can add a large amount at once:
Pine Script®

Finally, the state engine confirms trend changes. A bullish trend turns bearish when the downside sum exceeds the decision threshold on a closed bar, and a bearish trend turns bullish when the upside sum does the same, while from the warm-up state the first sum to cross sets the initial trend. Both sums reset to zero on every trend change, giving each new trend a clean slate, and states update on confirmed bars, so a confirmed trend change stays in place once the bar closes. The boundary line marks the level the source would have to reach on the next bar for the opposing sum to cross the threshold, which places it the threshold plus the allowance, in volatility units, away from price when no opposing evidence exists, and pulls it toward price as that evidence builds:
Pine Script®

Snapshot
🟢 Signal Interpretation

▶ Bullish Trend (Boundary Below Price with Bullish Color): When the upside sum clears the decision threshold, a trend change point marks the start of a boundary line below price, and the boundary line and evidence zone take on the bullish color, reading as buyers sustaining an advance persistently enough, or forcefully enough, to outweigh the allowance and confirm a new uptrend. Treat this as a long bias with the boundary as its invalidation level: pullbacks that close above it leave the trend intact, a deepening evidence zone and a boundary creeping closer to price show bearish evidence building, and the bias ends on the first close beneath the boundary, which turns the trend bearish.

▶ Bearish Trend (Boundary Above Price with Bearish Color): When the downside sum crosses the threshold, the trend change point and the boundary line appear above price in the bearish color, reading as sellers pressing a decline that has gathered enough evidence to overturn the prior advance. Treat this as a short bias with the boundary as its invalidation level: bounces that stall below it leave the trend intact, a strengthening zone tint warns that bullish evidence is accumulating against the decline, and the bias ends on the first close above the boundary, which turns the trend bullish.
Snapshot
🟢 Features

▶ Preconfigured Presets: Three parameter sets for different trading styles and timeframes. “Default” delivers balanced trend tracking for swing trading on 1H to daily charts, with the volatility length, drift allowance, and decision threshold adjustable directly. “Fast Response” is built for intraday work on 5 minute to 1H charts, shortening the volatility window and lowering the allowance and threshold so trend changes confirm after less accumulated evidence. “Smooth Trend” is aimed at position style reading on daily and weekly charts, lengthening the volatility window and raising the allowance and threshold so only larger, more persistent drifts confirm a change and trends hold through deeper pullbacks.
Snapshot
▶ Built-in Alerts: Three alert conditions support hands off monitoring. “Bullish Trend Signal” fires on the bar that confirms a bullish trend as the upside sum crosses the decision threshold. “Bearish Trend Signal” fires on the bar that confirms a bearish trend as the downside sum crosses it. “Any Trend Change” fires on either change. Alert messages include exchange, ticker, and timeframe for immediate context.
Snapshot
▶ Visual Customization: Six color presets (Classic, Aqua, Cosmic, Cyber, Neon, and Custom) apply coordinated bullish and bearish colors to the boundary line, boundary glow, evidence zone, trend change points, optional bar coloring, and optional background coloring. The bullish and bearish color pickers apply when Custom is selected. The glow, zone, trend change points, and both coloring options can each be toggled, with adjustable transparency for the bar and background tints, so the chart stays as clean or as expressive as the workflow requires.
Snapshot

Haftungsausschluss

Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.