Smart Algorithmic Trading Solution

Detrended Price Oscillator (DPO)


The Detrended Price Oscillator (DPO) is an indicator designed to remove trend from price and make it easier to identify cycles. DPO does not extend to the last date because it is based on a displaced moving average. However, alignment with the most recent is not an issue because DPO is not a momentum oscillator. Instead, DPO is used to identify cycles highs/lows and estimate cycle length.


Price {X/2 + 1} periods ago less the X-period simple moving average.

X refers to the number of periods used to calculate the Detrended Price
Oscillator. A 20-day DPO would use a 20-day SMA that is displaced by 11
periods {20/2 + 1 = 11}. This displacement shifts the 20-day SMA 11 days
to the left, which actually puts it in the middle of the look-back
period. The value of the 20-day SMA is then subtracted from the price
in the middle of this look-back period. In short, DPO(20) equals price
11 days ago less the 20-day SMA.

Displaced Moving Average

The moving average displacement actually centers the moving average. Consider a 20-day simple moving average offset 11 days to the left. There are 10 days in front of the moving average, 1 day at the moving average and 9 days behind the moving average. In reality, this moving average is in the middle of its look-back period. Roughly half the prices used in the calculation are to the right and half are to the left. Chart 1 shows the S&P 500 ETF (SPY) with a 20-day SMA (green dotted line) and a 20-day SMA offset 11 days (pink line). The ending values are the same (106.84), but the pink moving average ends on October 27th and the green moving average ends on November 11th, which is the last date on the chart. Also notice how the “centered” moving average (pink) more closely follows the actual price plot.

Chart 1

What Does DPO Measure?

The Detrended Price Oscillator (DPO) measures the difference between a past price and a moving average. Keep in mind that DPO is itself displaced to the left. The indicator oscillates above/below zero as prices move above/below the displaced moving average. Chart 2 shows the S&P 500 ETF (SPY) with a 20-day moving average displaced -11 days. 20-day DPO is shown in the indicator window. Notice how DPO is positive when price is above the displaced moving average and negative when price is below the displaced moving average.

Chart 2

Using DPO

Even though this indicator looks like a classic oscillator, it is not designed for momentum signals. The displaced moving average is set in the past and this is why the DPO is shown in the past. Even with this displacement, DPO peaks and troughs can be used to estimate cycle length. DPO filters out the longer trends to focus on shorter cycles. Chart 3 shows the Nasdaq 100 ETF (QQQQ) with DPO (20) in the indicator window. Looking at the peaks and troughs, we can see a 20-day cycle with the lows in early September, early October, early November and early December. There are roughly 20 days between these lows. The cycle missed in early January.

Chart 3

To Shift or not to Shift

It is possible to displace the Detrended Price Oscillator (DPO) with a horizontal shift to the right. If DPO is set at 20, then an 11 period shift is needed to place it in line with the most recent price. This displacement number comes from the formula at the top (20/2 + 1) = 11. While shifting may seem like a good idea, it really defeats the purpose of this indicator, which is to identify cycles.

Chart 4

Even with a positive displacement, DPO fluctuations do not match up well with prices. In the example below, the last value for DPO (20,11) is still based on the close 11 days ago and the value of the moving average. Notice that DPO turned negative as price moved below the centered moving average 11 days ago (orange box). DPO simply does not match current price action. In contrast to DPO, price has been below the 20-day EMA the last 12 days. The Percentage Price Oscillator (PPO) is better suited to identify overbought and oversold levels. PPO(1,20,1) shows the percentage difference between current price and the normal 20-day exponential moving average. Overbought/oversold conditions occur when prices get relatively far from their 20-day EMA.

Chart 5


The Detrended Price Oscillator shows the difference between a past price and a simple moving average. In contrast to other price oscillators, DPO is not a momentum indicator. Instead, it is simply designed to identify cycles with its peaks and troughs. Cycles can be estimated by counting the periods between peaks or troughs. Users can experiment with shorter and longer DPO settings to find the best fit.
Leave a Reply

You must be logged in to post a comment.

Follow me on Twitter

About FxMath

FxMath Financial Solution is a financial software team developing end-to-end algo trading systems for quantitative hedge funds and institutional trading groups. Our system based on profitable mathematical models with highest possible profit and lowest drawn down.


FxMath Financial Solution

Login Form

30% Discount For FxMath Harmonic Patterns Scanner
Pay 140$ instead 199$
Buy Now:


FxMath Harmonic Patterns Signals

Subscribe Free FxMath Harmonic Patterns Signals By Email

Join 1,926 other subscribers

Subscribe Free FxMath Harmonic Patterns Signals By Telegram:
Our Telegram Group: