On this page
Detrended Price Oscillator — Momentum, in its own panel below the chart.
What Detrended Price Oscillator measures
The shift is floor(N / 2) + 1 bars — 11 with the default period of 20. An N-period moving average lags the centre of its own window by (N − 1) / 2 bars, so stepping the close back by that amount lines it up with that centre, and what remains is the cycle component with the trend removed. Nothing is plotted before index max(N − 1, shift), since both the average and the past close have to exist. This is the non-centred variant: the value is drawn at the current bar index with no rightward offset, matching ATAS and TradingView's non-centred mode, but the number it carries describes the bar 11 back rather than the latest one. That is the cost of detrending, and it is structural, not a lag that can be tuned away.
The formula, as implemented
This is not how the indicator is usually defined elsewhere — it is what the shipped code computes, documented next to the implementation:
DPO — Detrended Price Oscillator. Retire la tendance en comparant un close PASSÉ à la moyenne (SMA SIMPLE) qui se termine MAINTENANT : shift = ⌊N/2⌋ + 1 DPO[i] = close[i − shift] − SMA_N(close)[i] LE DÉCALAGE, explicitement : la SMA_N centrée sur la fenêtre est « en retard » de (N−1)/2 barres sur son dernier point ; reculer le close de ⌊N/2⌋+1 le remet EN FACE du centre de cette moyenne. Le résultat est donc une mesure du cycle DÉBARRASSÉE de la tendance — mais il décrit la barre i − shift, PAS la barre courante. C'est la variante NON CENTRÉE : la valeur reste tracée à l'indice i (aucun décalage du tracé vers la droite), comme TradingView en mode non-centré et comme ATAS. Le DPO ne doit donc JAMAIS être lu comme un signal temps réel de la dernière barre : il est structurel- lement en retard de `shift` barres, c'est le prix du détrending. Défaut N=20 (shift = 11), la période cyclique usuelle. Warm-up → i ≥ max(N − 1, shift), donc N ≥ 2 imposé par le spec de param.
How to read it
- Positive means the reference close sat above the average ending now, negative means below. Zero is the detrended midpoint.
- Because the plotted value belongs to a bar several back, never read the last point as a statement about current price — it is a historical measurement drawn at today's x-position.
- The distance between successive peaks and troughs is what the oscillator was built for: it estimates the dominant cycle length in bars.
- If peaks and troughs arrive at irregular distances, the instrument has no stable cycle at that period and the output is measuring noise.
- Amplitude is expressed in price units, so it grows with volatility and cannot be compared across instruments.
Parameters and defaults
period (20) sets both the moving average and the shift, which is derived from it — there is no separate offset parameter to adjust. A shorter period shortens the shift and isolates faster cycles, a longer one filters more of the trend and pushes the reference further into the past. Choose the period from the cycle length you want to isolate, not from the reactivity you would like.
| Parameter | Type | Default | Range |
|---|---|---|---|
| Period | number | 20 | 2 – 500 |
What it does not show
The DPO is not a real-time indicator and must not be used as one: its latest value describes a bar several back by construction. Having removed the trend, it also says nothing about direction — a strongly trending market and a flat one can produce the same oscillation. It is price-only, with no volume, delta or liquidity input. And the detrending is only meaningful if a cycle of roughly the chosen length actually exists; where none does, the output is a smoothed residual carrying no information.
Related indicators
This page in other languages
Frequently asked questions
- Is the DPO shifted to the right on the chart?
- No. This is the non-centred variant, so each value is drawn at the bar where it is computed, exactly as ATAS and TradingView's non-centred mode do. The shift lives inside the formula — the close being compared is taken 11 bars back with the default period — not in the plot. The line is aligned with the chart, but the number is about an earlier bar.
- What does changing the DPO period change?
- It changes two things at once: the length of the moving average, and the shift, which is floor(period / 2) + 1. A period of 20 therefore compares the close from 11 bars ago with the 20-period average ending now. Longer periods strip out more of the trend and reach further back; shorter ones isolate faster cycles with less of the trend removed.
- Can the DPO be used as a real-time signal?
- It is not built for that. The value on the most recent bar is a measurement of a bar several back, so a fresh crossing of zero is describing something that already happened. The oscillator is meant for estimating cycle length and locating past turning points, and reading its last point as a live trigger misuses the formula.