> For the complete documentation index, see [llms.txt](https://chartschool.stockcharts.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://chartschool.stockcharts.com/table-of-contents/technical-indicators-and-overlays/technical-indicators/detrended-price-oscillator-dpo.md).

# Detrended Price Oscillator (DPO)

## What Is the Detrended Price Oscillator (DPO)? <a href="#introduction" id="introduction"></a>

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 date is not an issue because DPO is not a momentum oscillator. Instead, DPO is used to identify cycle highs/lows and estimate cycle length.

<figure><img src="https://436553459-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FERtrZrZOhufFzk6ZQO4B%2Fuploads%2FDdvoCF37kFsztlc15lAY%2Fdpoexample.png?alt=media&amp;token=920b275e-d416-474e-8278-5c40fcb6212e" alt=""><figcaption></figcaption></figure>

## Calculating DPO <a href="#calculation" id="calculation"></a>

The DPO is essentially comparing price with an SMA, but instead of comparing the latest price, it compares the SMA with the price that is right in the middle of the SMA's lookback period.

```
Price - X-period SMA from {X/2 + 1} periods in the future
```

The X in this formula 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 places it in the middle of the lookback period. The DPO(20) value for the bar in the middle of that lookback period would be price minus the 20-day SMA from 11 days in the future.

### Displacing the Moving Average <a href="#displaced_moving_average" id="displaced_moving_average"></a>

The moving average displacement actually centers the moving average. Consider a 20-day simple [moving average](/table-of-contents/technical-indicators-and-overlays/technical-overlays/moving-averages-simple-and-exponential.md) 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 lookback period. Roughly half the prices used in the calculation are to the right and half are to the left.&#x20;

The chart below shows the S\&P 500 ETF (SPY) with a 20-day SMA (green dotted line) and a 20-day SMA offset 11 days to the left (pink line). The ending values are the same (768.10), but the pink moving average ends on August 12th and the green moving average ends on August 27th, which is the last date on the chart. Also, notice how the “centered” moving average (pink) more closely follows the actual price plot.

<figure><img src="https://436553459-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FERtrZrZOhufFzk6ZQO4B%2Fuploads%2F209GlcxUF8IZw80dmOkZ%2Fdpo-1-spydisplaced.png?alt=media&amp;token=0f4ba1ed-4961-4e32-af35-0ab67b73698a" alt=""><figcaption><p>DPO compares price with an SMA shifted back half the number of periods in the SMA's lookback period</p></figcaption></figure>

### Comparing Price with the Displaced SMA <a href="#what_does_dpo_measure" id="what_does_dpo_measure"></a>

The Detrended Price Oscillator (DPO) measures the difference between a moving average and a price in the middle of the moving average's lookback period. Keep in mind that DPO is itself displaced to the left; no DPO values can be calculated based on future SMA values that do not exist yet.&#x20;

The indicator oscillates above/below zero as prices move above/below the displaced moving average. The chart below 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.

<figure><img src="https://436553459-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FERtrZrZOhufFzk6ZQO4B%2Fuploads%2FnOQqmlsj3R9wNPmFKDUI%2Fdpo-2-spymovingavg.png?alt=media&amp;token=b2731c66-6b40-42a2-a873-55f2c3cf88d3" alt=""><figcaption><p>DPO is positive when price is above, and negative when price is below, the displaced SMA</p></figcaption></figure>

## Interpreting DPO <a href="#using_dpo" id="using_dpo"></a>

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, which 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.&#x20;

The chart below displays the DPO (20) in the indicator window. Looking at the peaks and troughs, you can see a 10-day cycle with the lows in mid-December, early January, mid-January, early February, and mid-February. There are roughly 10 trading days between these lows. The cycle missed in March.

<figure><img src="https://436553459-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FERtrZrZOhufFzk6ZQO4B%2Fuploads%2FdkUOUUMeys91xpguwNMA%2Fdpo-3-qqqcycles.png?alt=media&amp;token=4dd3f196-197c-4b08-a943-d8a9cb35a31e" alt=""><figcaption><p>Measuring the time between DPO peaks or troughs helps determine cycle length</p></figcaption></figure>

### To Shift or Not to Shift <a href="#to_shift_or_not_to_shift" id="to_shift_or_not_to_shift"></a>

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.

In the chart below, the two indicator panels show a normal DPO(20) and a DPO(20) that has been shifted forward 11 days. The shifted-forward DPO(20) does not align well with current prices. While you could still use it to determine the average length of the cycles, it would not accurately show where a given bar is in the cycle.

<figure><img src="https://436553459-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FERtrZrZOhufFzk6ZQO4B%2Fuploads%2FHWv04uev33dQPzo9qPgq%2Fdpo-4-spyshift.png?alt=media&amp;token=1c317d4a-73fd-45b8-9794-b23e68ceb45a" alt=""><figcaption><p>DPO that is shifted forward does not match well with price movements</p></figcaption></figure>

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). A positively-displaced DPO simply does not match current price action.&#x20;

In contrast to the shifted DPO, price has been below the 20-day SMA the last 15 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.

<figure><img src="https://436553459-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FERtrZrZOhufFzk6ZQO4B%2Fuploads%2FjoqdSrDPbx1l6sgNs9Jv%2Fdpo-5-spyppo.png?alt=media&amp;token=cacf81fb-e18c-4fee-ad3f-03698285b12c" alt=""><figcaption><p>PPO is a better option for finding overbought/oversold conditions</p></figcaption></figure>

## The Bottom Line <a href="#conclusion" id="conclusion"></a>

The Detrended Price Oscillator shows the difference between a simple moving average and a price in the middle of the SMA's lookback period. 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.

***

## Charting with DPO <a href="#using_with_sharpcharts" id="using_with_sharpcharts"></a>

### Using with SharpCharts <a href="#using_with_sharpcharts" id="using_with_sharpcharts"></a>

The Detrended Price Oscillator (DPO) can be found in the indicator list on SharpCharts. The default parameter is 20 periods, but this can be adjusted accordingly to find cycles. Users can also add another parameter separated by a comma. A comma plus a positive number shifts the indicator to the right. DPO can be positioned above, below, or behind the price plot.&#x20;

[Click here for a live version of the chart.](https://stockcharts.com/sc3/ui/?s=SPY\&a=2346885084\&p=D\&b=5\&g=0\&id=p46067408982)

<figure><img src="https://436553459-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FERtrZrZOhufFzk6ZQO4B%2Fuploads%2FQraoIJL6pGDd2lAmKmcv%2Fdpoinshch.png?alt=media&amp;token=5918843d-5aa3-4735-890a-aea59fa181ed" alt=""><figcaption></figcaption></figure>

<figure><img src="https://436553459-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FERtrZrZOhufFzk6ZQO4B%2Fuploads%2F85yQeMMDdoXsfJOQes8n%2Fdpo-6-sharpcharts.png?alt=media&amp;token=0055dee7-6d21-4a93-9841-4aff78b4daf7" alt=""><figcaption><p>DPO and displaced SMA settings in SharpCharts</p></figcaption></figure>

{% hint style="info" %}
**Learn More:** For more details on the parameters used to configure DPO indicators, please see our [SharpCharts Parameter Reference](https://help.stockcharts.com/charts-and-tools/sharpcharts/sharpcharts-workbench/editing-sharpcharts/sharpcharts-parameter-reference#detrended_price_oscillator_dpo) in the Support Center.
{% endhint %}

### Using with StockChartsACP

This indicator can be added from the Chart Settings panel for your StockChartsACP chart. The indicator can be positioned above, below, or behind the security's price plot.

<figure><img src="https://436553459-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FERtrZrZOhufFzk6ZQO4B%2Fuploads%2F7mdWKleXk3kmgFyAyyym%2Fdpoinacp.png?alt=media&amp;token=5d3a5bd8-9519-4f4e-8c2b-c5a1ff17cb85" alt=""><figcaption></figcaption></figure>

[Click here for a live version of this chart.](https://schrts.co/CCIMmhqC)

By default, this indicator is calculated using 20 periods. This parameter can be adjusted to meet your technical analysis needs.

## Scanning for DPO <a href="#suggested_scans" id="suggested_scans"></a>

While StockCharts members can scan for stocks based on Detrended Price Oscillator values, the Detrended Price Oscillator is not well suited for scans, because the indicator is based on an offset moving average. A 20-day DPO correlates to a price 11 days ago, which is not practical for scans.&#x20;

DPO is also based on absolute levels, making it difficult to use for comparative purposes. A $100 stock will have a much wider DPO range than a $20 stock, and will typically have much larger DPO values.

{% hint style="info" %}
**Learn More.** For more details on the syntax for Detrended Price Oscillator scans, please see our [Scanning Indicator Reference](https://help.stockcharts.com/scanning-and-alerts/scan-writing-resource-center/scan-syntax-reference/scan-syntax-technical-indicators#detrended_price_oscillator_dpo) in the Support Center.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://chartschool.stockcharts.com/table-of-contents/technical-indicators-and-overlays/technical-indicators/detrended-price-oscillator-dpo.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
