Detrended Price Oscillator (DPO): The Cycle-Timing Tool That Strips Trend and Exposes Market Rhythm
Overview #
Most oscillators fail traders the same way — they conflate trend and cycle. RSI stays oversold for weeks in a bear market. MACD spits out signals that are already embedded in a move that's half over. Neither tool was designed to isolate what's actually happening underneath the price action: the rhythmic oscillation every market makes as it swings between supply and demand zones, regardless of the larger directional bias.
The Detrended Price Oscillator (DPO) solves this by doing something none of the popular oscillators do — it surgically removes the trend component and leaves only the cyclical residue. What you're left with is a clean oscillator that shows you exactly where price sits within its current swing cycle, stripped of directional noise. Peak = extended above the cycle mean. Trough = compressed below it. Zero line = detrended equilibrium.
That sounds abstract until you see it on a chart. When DPO troughs at the same time ES drops into a familiar support zone with a bullish pin bar, you're not guessing at a reversal — you're reading three confirming data streams telling the same story. That's the edge.
This guide covers everything: how the math works, how to set it correctly for ES, NQ, and CL, what the signals actually mean in live futures markets, how to avoid the traps that burn most DPO users, and how to wire it into a complete trading approach rather than treating it as a standalone crystal ball.
One thing upfront: DPO is a cycle-timing tool. It is not a trend-following tool. That distinction — which sounds obvious — kills more DPO setups than anything else. Get it wrong and you'll be fading every trend move with a smile on your face until your account says otherwise.
What the DPO Actually Does #
The DPO was developed in the 1970s as part of the cycle analysis movement that grew alongside J.M. Hurst's work on price cycles and the growing interest in applying Fourier analysis to financial markets. The core concept is elegant: if you want to see what a market's natural swing rhythm looks like, you first have to get the trend out of the way.
Traditional oscillators like RSI or Stochastics try to normalize price movement into a bounded range. They don't remove the trend — they just measure how far price has moved over a fixed lookback. That means in a strong bull trend, RSI can sit at 70+ for extended periods, telling you nothing useful about when the next corrective swing is likely. DPO takes a different approach.
The mechanism: DPO calculates a simple moving average and then shifts it backward in time by approximately half the lookback period. It then subtracts that displaced average from the current price. The displacement is what matters. A regular SMA follows price closely, lagging by the lookback period. When you shift it back, you're basically centering it in the middle of its lookback window — which is mathematically equivalent to comparing current price to the trend mid-point. Everything left over after that subtraction is cycle.
What you see in the DPO panel:
- Above zero: Price is currently running above the detrended cycle midpoint -- extended toward the cycle high
- Below zero: Price is running below the cycle midpoint -- compressed toward the cycle low
- Zero line: Price is at cycle equilibrium -- the detrended mean
- DPO peaks: Cycle highs, potential reversal points if confirmed
- DPO troughs: Cycle lows, potential reversal points if confirmed
The critical point: the zero line has nothing to do with whether the market is in an uptrend or downtrend. A market can be in a screaming uptrend while the DPO is oscillating above and below zero — showing you the swing rhythm within that trend. That rhythm is what you're trading.
The DPO doesn't predict direction. It shows you where you are in the current swing cycle. Use trend tools to know which direction to trade; use DPO to know when to enter.
The Formula in Plain Terms #
For a lookback period of N bars:
DPO = Current Close -- SMA(N) from (N/2 + 1) bars ago
For a 20-period DPO:
- Calculate a 20-period SMA
- Look at what that SMA's value was 11 bars ago (20/2 + 1 = 11)
- Subtract that value from the current close
The result oscillates around zero. When current price is above the mid-period SMA value, DPO is positive. When below, it's negative.
A concrete example with ES at 6412.25:
- ES 5-minute chart, DPO(14)
- Shift = 14/2 + 1 = 8 bars
- Current close: 6412.25
- SMA(14) from 8 bars ago: 6400.50
- DPO = 6412.25 -- 6400.50 = +11.75 points
That +11.75 tells you ES is currently running 11.75 points above its detrended cycle midpoint from 8 bars ago — it's in the upper half of the current cycle.
NexusFi member @Fat Tails spelled out exactly what the DPO actually measures in a thread about coding detrended oscillators:
@Fat Tails — NexusFi: How do you code a detrended oscillator?
The implication in that last sentence matters: because the DPO is measuring a relationship that includes a backward look, it is not a real-time momentum indicator. It tells you about the cycle position with a delay that is inherent in the construction. That delay is not a bug — it's exactly what allows the DPO to strip out trend noise.
NinjaScript Implementation (NinjaTrader 8)
// DPO Indicator Core Logic
int period = 14; // Adjust per instrument/timeframe
int shift = period / 2 + 1; // Backward displacement
// DPO Calculation
double sma = SMA(Close, period)[shift]; // SMA from 'shift' bars ago
double dpo = Close[0] - sma; // Detrended value
// Amplitude filter -- ignore low-conviction crosses
double atrValue = ATR(14)[0];
bool validSignal = Math.Abs(dpo) > atrValue * 0.5;
// Plot
Plot0.Set(dpo);
PlotZeroLine.Set(0);
The atrValue * 0.5 filter eliminates DPO signals that occur during dead, low-volatility periods where the oscillator bounces around zero without meaningful conviction. It's optional but adds real value.
Cycle Identification: Choosing the Right Period #
This is where most traders either get DPO right or get it wrong. The lookback period N is not arbitrary — it should reflect the dominant swing cycle of the instrument and timeframe you're trading. Set it too short and the DPO becomes choppy, flipping above and below zero on every minor fluctuation. Set it too long and the cycles you want to trade become invisible within the smoothing.
The simplest approach: look at recent chart history on your target timeframe and count the average number of bars between consecutive swing highs (or swing lows). That distance — not in price, in bars — is your starting cycle estimate.
A more rigorous approach is autocorrelation. NexusFi member @Nicolas11 documented his exploration of exactly this, experimenting with three different Ehlers methods for cycle identification:
@Nicolas11 — NexusFi: Nicolas' trading journal
| Instrument | 1-Min | 5-Min | 15-Min | Daily |
|---|---|---|---|---|
| ES (E-mini S&P 500) | 12 | 14--24 | 30--36 | 20--30 |
| NQ (E-mini Nasdaq 100) | 10 | 12--22 | 28--34 | 25 |
| CL (Crude Oil) | 16 | 18--25 | 30--48 | 20--35 |
| GC (Gold) | 14 | 18--24 | 32--40 | 22--28 |
| 6E (Euro FX) | 12 | 16--22 | 28--36 | 20 |
Measure your instrument. On a 5-minute ES chart, count the bars between the last 5--8 consecutive swing lows. Take the average. That number is your current dominant cycle estimate. Set DPO(N) to that value. Revisit every 4--6 weeks — cycles drift.
The market's cycle length shifts as volatility conditions change. NexusFi member @glennts' extensive work on cycle analysis makes this point clearly in the context of the 6E Euro futures:
@glennts — NexusFi: EURUSD M6E/6E Euro
Reading DPO Signals: What's Actually Useful #
There are three types of signals the DPO produces. Ranking them by reliability for futures trading:
Peak and Trough Reversals (Highest Value)
When the DPO reaches a local peak — meaning it has been rising, reached a new high, and started turning down — price has extended above its detrended cycle midpoint. This is a potential reversal point. The same logic applies in reverse at troughs.
This signal is most powerful when:
- The DPO extreme is confirmed by a price-action pattern at a known structural level (support, resistance, value area edge, pivot)
- Volume is declining into the extreme (absorption rather than expansion)
- The timeframe context supports a fade (ranging market, not trending)
Divergences (Moderate Value, Requires Confirmation)
Bearish DPO divergence: price makes a higher high, DPO makes a lower high. This tells you the cycle is losing upside momentum — the most recent push to a higher price extreme was less energetic than the prior one in cycle terms.
Bullish DPO divergence: price makes a lower low, DPO makes a higher low. The cycle is compressing less aggressively even as price continues printing lower lows — setup for a mean-reversion bounce.
DPO divergences in trending markets are traps. A market can make 10--15 consecutive DPO divergences as price grinds in one direction. Each one looks like a setup. None of them actually reverse until the trend exhausts. Require structural confirmation — a break of the prior swing high/low, a volume signature, or a price-action trigger — before trading any DPO divergence.
Zero-Line Crosses (Secondary, Filter Required)
When DPO crosses from negative to positive, price has shifted from below to above the detrended cycle mean. This is the most commonly taught signal but also the lowest-grade one for active futures trading. In choppy conditions, the DPO will cross the zero line repeatedly with no directional follow-through.
Zero-line crosses are useful as a regime signal: when DPO zero crosses are clean and widely spaced, the cycle is behaving. When they're rapid-fire and indecisive, the market is in a choppy, low-conviction regime and DPO signals should be deprioritized.
DPO vs. MACD vs. RSI: Choosing Your Tool #
| Dimension | DPO | MACD | RSI |
|---|---|---|---|
| Core function | Cycle phase identification | Trend momentum and acceleration | Overbought/oversold bounded measure |
| What it strips out | Long-term trend component | Nothing (measures trend directly) | Nothing (normalizes price movement) |
| Best market condition | Range-bound, consolidating | Trending | Any (with regime awareness) |
| Primary weakness | Countertrend signals in trends | Lags in choppy markets | Stays extreme during strong trends |
| For futures | Swing entry timing | Trend confirmation and bias | Entry bias filter |
The key insight: these tools are complementary, not competitive. A mature DPO-based trading approach uses DPO for timing, MACD or EMA slope for direction, and RSI as a filter.
A concrete multi-indicator setup for ES 5-minute:
- MACD(12,26,9) histogram is positive and above its signal line -- bullish bias
- RSI(14) is between 40 and 60 -- not overbought or oversold in momentum terms
- DPO(14) reaches a trough and starts turning up -- cycle low is in, entry timing aligns
- Entry: long on the next bullish 5-minute candle
- Stop: 1.5 x ATR(14) below the DPO trough low
- Target: first zero-line cross or 0.8 x ATR profit, whichever comes first
Best Setups for ES, NQ, and CL #
ES -- The Mean Reversion Fade
ES at 6412.25 is the most liquid futures market on the planet. Its 5-minute chart shows consistent micro-cycle behavior during range-bound sessions, making it one of the better instruments for DPO work.
Setup: DPO Trough Long with Structural Confirmation
Context: ES at 6412.25 after a 30-point morning decline from 6442.25 to 6412.25. Price has been consolidating in a 15-point range for 45 minutes.
- Chart: ES 5-minute, DPO(14)
- DPO currently at -18 points (below -15 = extended cycle compression)
- MACD(12,26,9): Histogram turning positive after being negative
- ADX(14): Below 20 (range market confirmed)
- Structure: Prior day low at 6404.25, current price at 6412.25
Entry: Long at 6413.75 on DPO trough + MACD flip + structural support
Stop: 6405.75 (below prior day low, 1.5 ATR)
Target: 6424.25 (zero-line cross of DPO, approximately)
NQ -- Faster Cycles, Tighter Setups
NQ at 23328.5 moves faster and has sharper intraday swings than ES. The cycle frequency is higher, which means DPO periods should be slightly shorter and entries need to be tighter.
Setup: NQ DPO Divergence Short at Resistance
- Chart: NQ 5-minute, DPO(20)
- Price makes a new session high at 23358, DPO makes a lower high compared to the prior peak (bearish divergence)
- EMA(20): Price is at the EMA from above, flat (range conditions)
- Volume: Declining on the second push to highs (absorption)
Entry: Short at 23354 on bearish 5-minute candle close
Stop: 23394 (above session high + 10-point buffer)
Target: 23328 or DPO zero-line cross
CL -- Regime Matters Most
CL at 99.64 is a different animal. Crude has genuine fundamental drivers — inventory reports, OPEC decisions, geopolitical events — that can blow through any technical structure in minutes. DPO works on CL specifically when the market is not in one of those event-driven trending phases.
Setup: CL 15-Min Range Play
- Chart: CL 15-minute, DPO(36)
- DPO currently at -3.80 (meaningful trough for CL at this price level)
- EMA(20): Flat, price slightly below
- ADX(14): 14 (firmly in range territory)
Entry: Long at $99.64 near the range low
Stop: $97.84 (below range support)
Target: $103.14 (range midpoint) or DPO zero-line cross
Never hold a DPO-based CL trade through an EIA inventory report or OPEC announcement. The fundamental trigger will override any cycle-based signal. Know your calendar.
Regime Filter: The Non-Negotiable Rule #
The regime filter draws the line between traders who profit from DPO and traders who lose money to it. The concept is simple: DPO is a ranging-market tool. You must filter out signals when the market is trending.
The standard approach: ADX(14) below 20 indicates a ranging market. When ADX is below 20, DPO cycle signals have higher probability. When ADX is above 25 — indicating a developing trend — DPO signals should be deprioritized or traded only in the trend direction.
@iantg documented this filtering principle in his trading journal:
@iantg — NexusFi: Outside the Box and then some...
Inverted: when trend strength is high, filter out DPO countertrend signals.
Common Mistakes #
Mistake 1: Using DPO for Trend Trading
This is the number one error. DPO is detrended by design. In a strong uptrend, the cycle midpoint itself is trending up. The DPO will make peaks — but those peaks are happening at progressively higher price levels. Trading every peak in a trending ES session is a textbook way to give money to trend traders.
Mistake 2: Static Period Across All Conditions
Market cycles shift as volatility conditions change. NexusFi member @sefstrat's extensive work on cycle indicators illustrates why even advanced signal processing techniques fail when the underlying assumptions don't hold:
@sefstrat — NexusFi: Market Cycles For Fun & Profit
Mistake 3: Contract Roll Day Signals
When futures contracts roll, the price gap creates a discontinuity that shows up in the SMA calculation DPO uses, generating false peaks and troughs around the roll date. Fix: Exclude roll day data or avoid trading DPO signals in the first 30 minutes after rollover.
Mistake 4: Over-Optimizing the Period
The N that maximized performance on historical data is specifically optimized for that history. When market conditions change, the optimized N typically underperforms a reasonable starting value. Use walk-forward optimization: calibrate on 12 months, test on the next 3 months out-of-sample. Robustness beats historical peak performance.
Combining DPO with Order Flow #
For traders who have access to footprint charts, DOM, or cumulative delta, DPO can be integrated as the cycle timing layer in a more complete analytical framework.
The core integration: use DPO to identify when a cycle trough or peak is likely, then use order flow confirmation to time the entry precisely.
When the DPO shows cycle exhaustion at a structural support level, look for:
- Delta absorption: cumulative delta was negative but flipped positive at this level
- Bid stacking in the DOM: significant bid size appearing at the support
- Time and sales: trades at the bid slowing, trades at the ask accelerating
The best DPO setups have three layers: structural context (where is price relative to value areas, pivots, overnight range?), cycle position (where is DPO in its oscillation?), and execution trigger (order flow, price action candle, or volume signature). When all three align, you have a trade worth taking.
Multi-Timeframe DPO: Building a Coherent Picture #
Single-timeframe DPO analysis has limits. The multi-timeframe framework:
- Higher timeframe (daily/60-min): Sets directional bias. Daily DPO positive and rising? Look for long setups on lower timeframes.
- Intermediate timeframe (15-min/5-min): Identifies cycle turning points. This is where most of the signal quality lives for day trading.
- Entry timeframe (1-min/tick): Refines entry within the intermediate cycle. A 1-minute DPO trough within an intermediate 5-minute DPO trough is a higher-precision entry.
The rule that prevents getting lost in multi-timeframe analysis: direction comes from the higher timeframe; entry timing from the intermediate; execution trigger from the lower timeframe. Never reverse this hierarchy.
If your higher timeframe DPO is still declining (in a peak), don't let a fresh 5-minute DPO trough talk you into a long. The larger cycle overwhelms the smaller one. Wait for the higher timeframe to turn before leaning on lower timeframe entries in that direction.
NexusFi member @Nicolas11 explored adaptive cycle detection across multiple timeframes. The principle is consistent: the dominant cycle varies by timeframe, and the alignment of cycle turning points across timeframes produces the highest-probability entries.
Risk Management When Trading DPO Setups #
DPO setups are mean-reversion setups by nature. Mean-reversion risk management has specific characteristics:
Stop placement: Structural stops, not indicator-based stops. The stop goes beyond the structural level that invalidates the setup. If you're long because DPO troughed at a prior day's low, the stop goes below that prior day's low.
Position sizing: Scale position size to risk 1--2% of account equity based on the distance to the structural stop, not a fixed lot count.
Target selection: Mean-reversion targets are typically the prior range midpoint, a known structural resistance level, or the zero-line cross of the DPO. Don't target the next cycle peak — you're trading a bounce within the cycle.
Daily loss limits: Mean-reversion strategies can chain losses in a trending day. If DPO keeps giving you trough signals in a downtrending session and you keep getting stopped out, stop after 2--3 consecutive stops. If ADX has crept above 25 while you were getting stopped out, the regime changed and DPO should be paused.
Three consecutive stopped-out DPO setups on the same instrument in the same session is a signal, not bad luck. It means the market is trending and DPO is generating countertrend signals. Reassess the regime before continuing.
DPO in Automated Trading Systems #
For traders building algorithmic strategies, DPO has distinct characteristics that affect implementation.
What works:
- DPO as a filter: include DPO cycle position as a condition (only take MACD crossover signals when DPO is below the zero line for longs, above for shorts)
- DPO regime classification: use DPO oscillation amplitude as a market regime signal. When DPO amplitude is contracting, volatility is compressing. When expanding, the market is in an active cycle.
What doesn't work:
- DPO-only systems: backtested DPO-only systems show poor performance because the indicator was not designed to generate standalone signals
- Static parameter optimization: the optimal N for a historical sample rarely survives live trading
@sefstrat's particle oscillator work in NexusFi's Elite Circle explores the same detrending concept as DPO — his d9ParticleOscillator (189 thanks) uses adaptive filtering rather than a fixed SMA shift. His conclusion: more modern adaptive techniques handle non-stationary market data better than static-period approaches, which applies equally to DPO period selection.
Platform-Specific Setup Notes #
NinjaTrader 8: DPO is available as a built-in indicator. Add via the Indicator menu. Default period is typically 14 or 20. Add a zero line via the Plots tab. The ATR amplitude filter requires a custom NinjaScript indicator — the standard NT8 DPO doesn't include this.
Sierra Chart: Available as "Detrended Price Oscillator" under Studies. Sierra's version offers parameter control for both the period and the shift. Also available as a custom study script.
TradingView (Pine Script):
// DPO in Pine Script
length = input(14, title="DPO Length")
dpo = close - ta.sma(close, length)[length/2 + 1]
plot(dpo, color=dpo >= 0 ? color.green : color.red)
hline(0, color=color.yellow, linestyle=hline.style_dashed)
MultiCharts: Available via PowerLanguage indicator. EasyLanguage compatibility means most TS-coded DPO versions port directly.
Practical Framework: Complete Decision Process #
Pulling everything together into a trading decision framework:
- Regime check: Query ADX(14). Below 20 = high-probability DPO environment. Above 25 = pause DPO or trend-direction only.
- Higher timeframe bias: Check 60-min DPO direction. Positive = look for trough longs on 5-min. Negative = look for peak shorts.
- Cycle timing: Wait for DPO to reach an extreme consistent with higher timeframe bias. Confirm |DPO| > 0.5 x ATR(14) to qualify as a valid extreme.
- Entry trigger: Price action confirmation -- bullish pin bar, engulfing candle, or structural rejection. Optional: order flow confirmation for higher-precision entries.
- Position sizing: Identify structural stop, calculate risk in points/ticks, size to risk 1--2% of equity.
- Exit management: First target at prior structural level or DPO zero-line cross. Trail stop using ATR after first target is hit. Hard exit before major news events.
Summary: When to Use DPO and When to Walk Away #
Use DPO when:
- The market is in a consolidation or range-bound phase (ADX below 20)
- You're timing entries within a confirmed structural context
- You have higher timeframe bias confirmed and need lower timeframe entry precision
- You're building a multi-indicator setup where DPO is the cycle-timing component
Skip DPO when:
- The market is in a strong trend (ADX above 25)
- Major news events are imminent (Fed, NFP, CPI, OPEC, inventory data)
- You're trying to identify trend direction (use MACD, moving average slope instead)
- You're in a contract roll window (first 30 minutes post-roll)
The core principle, stated plainly: DPO strips the trend so you can see the market's swing rhythm. That rhythm is real — markets do oscillate, even within trends. The mistake is trying to trade that oscillation against the trend. Trade the rhythm in the direction the trend allows, time entries with DPO at cycle extremes, and let the market's natural rhythm work for you rather than against you.
The traders on NexusFi who've worked cycle analysis seriously — @glennts' decade-plus of analysis, @Nicolas11's systematic exploration of Ehlers' adaptive methods, @Fat Tails' rigorous technical implementations, @sefstrat's particle-based extensions — all arrive at the same conclusion: cycles are real, but they require a framework to trade effectively. The DPO is one tool within that framework. Used correctly, it adds precision to entries that structural analysis alone can't provide.
Knowledge Map
Prerequisites
Understand these firstGo Deeper
Build on this knowledgeReferences This Article
Articles that build on this topicCitations
- — How do you code a detrended oscillator? (2013) 👍 1
- — Cycle Analysis... a way of looking at price action. (2022) 👍 5
- — Market Cycles For Fun & Profit (2009) 👍 5
- — Nicolas' trading journal (2014) 👍 4
- — d9ParticleOscillator (2009) 👍 189
- — Webinar: John Ehlers on Indicators for Effective Trading Strategies (2013) 👍 37
- — EURUSD M6E/6E Euro (2022) 👍 3
- — Outside the Box and then some.... (2016) 👍 19
- — Cycle Analysis... a way of looking at price action. (2022) 👍 14
