# Detrended Price Oscillator (DPO)

## Calculation

```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. ## 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. ## 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. ## 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. ###### 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. ## Conclusions

### Privacies

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.

### Big Discount Offer

FxMath Scanner 50% discount code: RezaOff50