All indicators

Detrended Price Oscillator

By LuxAlgoApr 13, 2020

Static chart image

The Detrended Price Oscillator subtracts a displaced simple moving average from price, removing the longer trend so shorter cycles stand out around a zero line. With the average shifted by Length / 2 + 1 bars, everything slower than the lookback drops out, leaving the local cyclical swing. Its classic job is measurement — locating cycle turns, counting the bars between them, and gauging stretch from the local mean.

This build follows the standard published formula exactly, with a default length of 21 and the conventional Centered option, which shifts the plot back so the oscillator aligns with the prices that produced it. The DPO line draws in its own pane against a dashed zero line.

How to Trade the Detrended Price Oscillator?

  • Sign of the reading: above zero, price trades above its displaced average — the high side of the short cycle; below zero, the low side.
  • Zero-line crosses: the cycle is rotating across the mean; bullish and bearish zero-cross alert conditions are included.
  • Trough-to-trough spacing: bars between successive DPO lows (or highs) estimate the length of the cycle in play.
  • Unusual extremes: readings far outside the recent range mark unusual stretch.

Everything slower than the lookback is removed by design, so the DPO says nothing about the larger trend — pair it with a separate trend read.

Detrended Price Oscillator Settings

  • Length (default 21): lookback of the simple moving average price is detrended against, displaced by Length / 2 + 1 bars. Only cycles shorter than the length survive — raise it for slower swings, lower it for faster ripples.
  • Source (default close): the price series used in the detrending calculation.
  • Centered (default off): shifts the oscillator back by Length / 2 + 1 bars so each value sits on the prices it detrends; the most recent bars then show no value.

Frequently Asked Questions

How is the DPO different from a momentum oscillator like Rate of Change?

Rate of Change measures distance from one past price, so the trend stays embedded in the reading. The DPO subtracts an average displaced to the middle of its own window, cancelling the trend and leaving the cycle oscillating around a stable zero line.

Should I enable the Centered option?

Enable it to study completed cycles: the plot lines up with the price that generated it, at the cost of the last Length / 2 + 1 bars showing nothing. Leave it off for a reading that updates to the current bar, accepting a comparison against an average from several bars back.

What is the best length for the DPO?

There is no universally right number — the length acts as a filter, so set it slightly longer than the cycle you want to see. The default of 21 suits swing-scale cycles on most charts.

Free indicator

Get free access to this indicator on the platforms below.

TradingView
NinjaTrader
MetaTrader 4/5

The Library is free. Quant makes it yours.

Pull any concept or indicator into Quant: rebuild it, retune it, or turn it into a backtested strategy of your own.