← Back to Home
Trading Signal / Indicator
📉

Detrended Price Oscillator (DPO)

Isolate short-term price cycles by removing the long-term trend.

Start Automating Free →

Want to automate this strategy? Try auto-Trading free — no credit card required.

Detrended Price Oscillator (DPO) chart

Overview

What is Detrended Price Oscillator (DPO)?

The Detrended Price Oscillator (DPO) is a unique indicator that removes the long-term trend from price action to isolate short-term price cycles. Unlike most oscillators that measure momentum relative to recent price action, the DPO shifts a moving average backward in time and subtracts it from price — effectively "detrending" the data to reveal the natural price cycle.

Formula: DPO = Close − Simple Moving Average(N/2 + 1 periods ago). By using a displaced (shifted back) moving average, the DPO aligns the cycle peaks and troughs with the actual price peaks and troughs — making it easier to identify the cycle length and time entries at cycle lows.

The primary use is cycle timing: count the number of bars between consecutive DPO peaks (or troughs) to determine the dominant cycle length of an instrument. Once the cycle is known, traders anticipate when the next cycle low will occur and position for a bounce. This is particularly valuable for instruments with consistent seasonal patterns or well-defined trading cycles.

DPO also identifies overbought/oversold conditions relative to the cycle: when DPO reaches its historically highest readings, price is at a cycle peak and a correction is likely. When DPO is at its historically lowest readings, price is at a cycle trough and a bounce is expected.

Important note: the DPO is not designed as a momentum indicator for trend trading — it is a cycle analysis tool. Using it to trade against strong trends will result in many premature entries.

How It Works in auto-Trading

Automate It

auto-Trading implements DPO with configurable period and displacement. The strategy builder supports DPO overbought/oversold threshold signals, zero-line crossovers, and peak/trough detection for cycle analysis. DPO is most effective when combined with a trend filter (trade DPO cycle lows only when the 200 EMA is rising) to avoid counter-trend entries in strong moves.

Try Free →

Strategy Code

Pick a script below, copy it, and use it on your chart.

Pine Script (TradingView)

This is a TradingView Pine Script example for this indicator. Paste it into the TradingView Pine Editor, add it to your chart, and adjust inputs for your market and timeframe.

//@version=6
strategy("Detrended Price Oscillator (DPO)", overlay=true)
fastLen = input.int(20, "Fast Length")
slowLen = input.int(50, "Slow Length")
fast = ta.ema(close, fastLen)

Get full strategy code access

Enter your email address and full name to unlock this strategy code.

ThinkScript (thinkorswim)

This is a thinkorswim ThinkScript example for this indicator. Open thinkorswim, create a custom study, paste the script, and apply it to your chart.

input length = 20;
def dpo = DetrendedPriceOsc(length = length);
def buySignal = dpo crosses above 0;
def sellSignal = dpo crosses below 0;
AddOrder(OrderType.BUY_AUTO, buySignal, close, 1, Color.GREEN, Color.GREEN, "DPO Buy");

Get full strategy code access

Enter your email address and full name to unlock this strategy code.

Ready to automate Detrended Price Oscillator (DPO)?

Join thousands of traders who use auto-Trading to execute this strategy automatically, 24/7.

Get Started Free →

All Strategies & Signals

Continue Learning

Trading Strategies

Trading Signals & Indicators