Most indicators we use on Indian charts are built to tell us which way the trend is pointing. The detrended price oscillator (DPO) does the opposite. It deliberately strips the trend out of price so that what is left behind, the regular rise-and-fall rhythm, becomes easier to see. If a stock tends to bottom every few weeks, DPO is one of the cleaner ways to measure that gap.
That makes it an odd tool, and a lot of traders misuse it. They plot it, see a line wiggling around zero, and start treating it like RSI. It isn’t built for that. This guide walks through what DPO actually calculates, why it always looks “late”, and how to use it for the one job it does well: estimating cycle length.
In this article
- What the detrended price oscillator measures
- The DPO formula, step by step
- A worked example with a hypothetical stock
- Why DPO always stops short of today
- Reading the oscillator: above zero, below zero
- Using DPO to measure cycle length
- Where DPO falls short
- DPO next to other cycle tools
- A short checklist before you use the detrended price oscillator
What the detrended price oscillator measures
According to StockCharts’ ChartSchool, DPO is designed to remove trend from price and make cycles easier to identify. ChartSchool is blunt that it is not a momentum oscillator. Its purpose is to locate cycle highs and lows and estimate how long a cycle lasts.
The idea is simple. A long-ish moving average captures the trend. If you compare price with that average, the difference tells you how far price has swung above or below the trend. Remove the trend, and you are left with the swings.
The twist is which price DPO compares against the average. It does not use today’s close. It uses the close from the middle of the moving average’s lookback window.
The DPO formula, step by step
Investopedia gives the formula as:
DPO = Price from (X/2 + 1) periods ago − X-period simple moving average
Here X is the lookback period. Investopedia lays out the calculation in four steps:
- Pick a lookback period, say 20.
- Find the closing price from X/2 + 1 periods ago. With 20 periods, that is the close from 11 periods ago.
- Calculate the simple moving average (SMA) of the last X closes, here the last 20.
- Subtract the SMA from that older close. The result is the DPO value.
ChartSchool describes the same thing from a different angle. A 20-day DPO uses a 20-day SMA displaced by 11 periods (20/2 + 1 = 11). Shifting the average 11 days to the left places it in the middle of its own lookback window, with 10 days in front of it, 1 day at it and 9 days behind it. In other words, the average gets centred on the data it was built from, and price is compared with the average at that centre point.
DPO is not trying to tell you what price is doing today. It is trying to tell you how long the swings have been lasting.
A worked example with a hypothetical stock
Numbers make this click faster than words. Take a hypothetical Stock A with these 20 daily closes (in rupees), day 1 being the oldest and day 20 the latest:
| Days | Closes (Rs) |
|---|---|
| 1 to 5 | 412, 415, 419, 423, 428 |
| 6 to 10 | 431, 434, 436, 438, 435 |
| 11 to 15 | 431, 427, 424, 422, 425 |
| 16 to 20 | 429, 433, 437, 440, 442 |
Step 1: the 20-day SMA. The 20 closes add up to Rs 8,581. Divide by 20 and the SMA is Rs 429.05.
Step 2: the close from 11 periods ago. Counting back 11 sessions from day 20 lands on day 9, which closed at Rs 438.
Step 3: subtract. DPO = 438 − 429.05 = +8.95.
This value belongs to day 9, not day 20. That is the bit people miss. On the chart, the reading sits back in the middle of the window, because that is the bar it describes. Day 9 was close to a local high in our series, and DPO is positive, which is what we would expect: price at that point was above the centred average.
Now roll forward one day. Suppose day 21 closes at Rs 445. The new 20-day window runs from day 2 to day 21 and sums to Rs 8,614, so the SMA becomes Rs 430.70. Eleven sessions back from day 21 is day 10, which closed at Rs 435. DPO = 435 − 430.70 = +4.30, plotted at day 10.
Notice what happened. Stock A made a fresh high on day 21, yet the newest DPO value fell. That isn’t a contradiction. DPO is reporting that day 10 sat less far above its centred average than day 9 did. It is describing the swing that peaked around day 9, not reacting to the latest close.
Why DPO always stops short of today
Both sources make the same point: DPO does not extend to the latest bar. With a 20-period setting, the most recent reading describes the close from 11 periods ago. ChartSchool adds that this is not really a problem, because DPO was never meant to be a momentum tool. Its job is to show past peaks and troughs so you can measure the spacing between them.
ChartSchool also notes that a 20-day DPO correlates to a price 11 days ago, which makes it a poor fit for stock scans. Keep that in mind before building a screener around DPO crossing zero. By the time the reading appears, the move it describes is already more than two trading weeks old.
Should you shift DPO forward?
Some charting packages let you shift DPO to the right so its last value lines up with the latest price. With DPO(20), that shift would be 11 periods. ChartSchool’s view is that shifting “defeats the purpose”: the shifted line no longer lines up with the price bars it was calculated from, so you lose the ability to see where a given bar sits within the cycle. We agree. If you want a reading that lines up with today’s price, DPO is the wrong indicator.
Reading the oscillator: above zero, below zero
The interpretation of the line itself is straightforward:
- When the older price (X/2 + 1 periods ago) is above the SMA, DPO is positive.
- When it is below the SMA, DPO is negative.
- The peaks in DPO line up with swing highs in price, and the troughs line up with swing lows.
What you do not get is a fixed overbought or oversold band. DPO is measured in price points, not percentages. ChartSchool points out that a $100 stock will typically show a much wider DPO range than a $20 stock. The same applies on Dalal Street: a stock trading near Rs 4,000 will throw up much bigger DPO swings in absolute terms than one trading near Rs 400, even if both are moving by similar percentages.
A quick illustration with our hypothetical numbers. If a Stock B traded at exactly ten times Stock A’s prices, its day-9 DPO would be +89.50 against an SMA of Rs 4,290.50. In percentage terms, both readings are the same, about 2.09% of the SMA. The raw DPO values, though, differ by a factor of ten. So never compare DPO readings across stocks, and be careful comparing them across long stretches of the same stock if the price level has changed a lot.
For overbought and oversold work, ChartSchool suggests a different tool altogether: the Percentage Price Oscillator, which expresses the gap between current price and a 20-day EMA in percentage terms.
Using DPO to measure cycle length
This is where the indicator earns its place. Investopedia describes the routine traders follow: mark the historical troughs (or peaks) on DPO, draw vertical lines through them, and count the time between them. If bottoms have tended to come about two months apart, you can locate the most recent bottom and project the next one roughly two months later.
Let’s run a hypothetical. Suppose that on a daily chart of some stock, DPO(20) troughs show up on trading days 7, 21, 33 and 49 of a stretch you are studying.
- Day 7 to day 21: 14 sessions.
- Day 21 to day 33: 12 sessions.
- Day 33 to day 49: 16 sessions.
The average gap is (14 + 12 + 16) / 3 = 14 sessions. If the rhythm holds, the next trough would be due somewhere around day 63, give or take a couple of sessions given how much the gaps varied. That is a window, not a date. You would then watch price action in and around that window for a reason to act, rather than buying blindly on day 63.
Investopedia also suggests using the trough-to-peak distance to estimate how long a long trade might run, and the peak-to-trough distance for a short trade. That is a useful way to set expectations for holding periods.
A cycle count gives you a window to watch, not a date to buy. Price still has to confirm.
Picking the lookback
Investopedia says the indicator is typically set to look back over 20 to 30 periods, and StockCharts uses 20 as its default. ChartSchool encourages experimenting with shorter and longer settings to find the best fit for the cycles you are studying. A shorter lookback picks up faster, smaller swings. A longer one smooths those out and shows broader cycles. There is no “correct” number; the right one is whichever makes the troughs on DPO line up cleanly with the visible swing lows on price.
Where DPO falls short
Investopedia lists the limitations clearly, and they are worth taking seriously:
- No signals on its own. DPO is a timing aid. It doesn’t tell you to buy or sell.
- Cycles change. There is no guarantee the historical cycle length repeats. Cycles can stretch or shrink.
- It ignores the trend. That’s by design, but it means you have to decide the direction yourself. If a stock is in free fall, buying at a “cycle bottom” may simply mean buying before the next leg down.
- Uneven peaks and troughs. Not every DPO peak or trough reaches the same level. A small dip on DPO can still mark an important turn in price, which is why you should mark the swings on price as well as on the indicator.
Investopedia’s practical suggestion follows from this: in an overall uptrend, cycle bottoms are more likely to be useful buying opportunities and peaks useful selling points. In other words, decide the trend with a separate tool, then use DPO only for timing within that trend.
DPO next to other cycle tools
It helps to know where DPO sits among its cousins. Investopedia contrasts it with the commodity channel index. Both try to capture cycles, but DPO is mainly about the time from peak to peak or trough to trough, while CCI focuses more on when a major move may be starting or ending.
That split suggests a sensible pairing. Use a trend tool (a longer moving average, ADX, or simply higher highs and higher lows) to decide direction. Use DPO to estimate when the next pullback low is likely to arrive. Then use price action, support levels or a momentum oscillator to confirm the turn when it comes. Our technical analysis guide for Indian stocks covers those building blocks if you want to set the rest of the toolkit up first.
A short checklist before you use the detrended price oscillator
- Decide the trend separately. DPO will not do it for you.
- Choose a lookback (20 is the common default) and check that DPO troughs line up with visible swing lows on price.
- Mark at least three or four troughs or peaks and measure the gaps between them in sessions.
- Average the gaps and note how much they vary. Wide variation means a wide window.
- Project the next window from the most recent confirmed trough or peak.
- Wait for price to confirm a turn inside that window before acting, with a stop-loss in place.
- Don’t compare raw DPO values across stocks, and don’t use it for scans.
Used this way, DPO is less a signal generator and more a ruler. It measures the rhythm a stock has been keeping. Whether that rhythm continues is something only the next few swings can tell us.
Disclaimer: This article is for educational purposes only and is not investment advice. Stock A, Stock B and all prices, DPO values and cycle dates used in the examples are hypothetical and used only to explain the arithmetic. Investments in the securities market are subject to market risks. Consult a SEBI-registered investment adviser before making investment decisions.

Leave a Reply
Join the conversation
Commenting is open to registered readers. Sign up with just your email — no password needed, and it takes under a minute.
Sign up to comment Log in