Cusum
Cusum (cumulative sum) accumulates the shift of bar returns measured in their standard deviations: a rise accumulates above zero, a fall below zero. When the sum crosses the threshold, it signals a lasting change of direction rather than a single bar.
The indicator is drawn in a separate area below the chart.
How to read it
- The green Up line rose above the upper threshold — a lasting rise.
- The red Down line fell below the lower threshold — a lasting fall.
- After a signal, the sum starts from zero.
Drift filters out small shifts: they do not accumulate. Threshold sets the balance between how often and how early signals come: the higher it is, the fewer false signals, but the later the real ones.
How it is calculated
- The bar return r = ln(price / price of the previous bar); the price is set by Source.
- σ is the square root of the EMA of squared returns over Period of σ, from past bars; the starting value is the average of the first squares over the period.
- The return is converted to σ: z = r / σ.
- The rise sum S⁺ = max(0, S⁺ + z − drift), the fall sum S⁻ = max(0, S⁻ − z − drift). The Down line draws −S⁻, that is, below zero.
- A sum above the threshold is a signal. On the signal bar you see the value beyond the threshold; from the next bar the sum starts from zero.
The first value appears on bar number Period of σ + 2 (bar 22 with the default settings). If the price stood still and σ is zero, z is taken as zero.
On the forming bar, the sum can cross the threshold and come back before the bar closes; the values of closed bars do not change.
Parameters
| Parameter | Description | Default |
|---|---|---|
| Period of σ | The period of the EMA of squared returns for σ, at least 1. | 20 |
| Drift | How many σ per bar are subtracted from the sum, 0 to 10 in steps of 0.1. Smaller shifts do not accumulate. | 0.5 |
| Threshold | A signal when the sum is above this many σ, 0.5 to 100 in steps of 0.5. Usually 4–5. | 4 |
| Source | The bar price: Close — the close, Median — (High + Low) / 2, Typical — (High + Low + Close) / 3. | Close |
Plots
| Parameter | Description | Default |
|---|---|---|
| Up | The accumulated rise in σ. | Green, solid |
| Down | The accumulated fall in σ, below zero. | Red, solid |
| Threshold | The threshold lines above and below zero. | Blue, dashes, no label |
Style
The lines have the Plot (show the line), Label (show the last value on the right scale), Color, Width (1–5) and Style (Solid, Dashes, Dots) fields. The value of the threshold lines is not shown next to the indicator name.
How to add an indicator to the chart is described in Adding an indicator; parameters are changed in the indicator manager.