The Detrended Price Oscillator removes the long-term trend from price to expose the underlying cycle rhythm — revealing overbought and oversold levels that pure trend indicators miss entirely.

Mean Reversion
Category
Intermediate
Difficulty
Unbounded oscillator (centered at zero, price-unit scale)
Output Range
20
Default Period
Moderate — displaced price reference creates visual appearance of centering
Repaint Risk
Simple — close price only
Data Need
MEANREVERSION · FILTER · CODE_HEAVY · LAGGING · REAL_TIME · REPAINT_RISK
Tags

Section 1: Core Mechanics

The DPO eliminates the dominant trend by comparing a displaced past price against a simple moving average. What remains is the cyclical component of price — the oscillation around the trend line.

Formula

Where is the period (default 20), and the displaced close is the price from bars in the past. For N=20, this is the close from 11 bars ago minus today's 20-period SMA.

Why the displacement? The SMA(20) is centered at bar 10 (the middle of a 20-bar window). Comparing the price at bar 10 against the SMA at bar 10 gives a "centered" oscillator — this is mathematically equivalent to the above formula without looking forward at all. The displacement is backward-looking, not forward-looking.

Inputs

  • Price source: Close price (standard)
  • Period (N): Number of bars. Default = 20. Controls cycle identification range.

Parameters

Parameter Default Range Impact
Period (N) 20 10–60 Higher N identifies longer cycles, more smoothing
Price source Close Close / HL2 Minimal difference — Close is standard
Displacement N/2 + 1 Fixed to formula Not user-adjustable — changes the indicator type

Output Range and Meaning

DPO outputs in price units (same as the close price). Positive values mean the displaced price is above the SMA — price was elevated relative to its trend at that cycle point. Negative values mean the displaced price was below the SMA.

The oscillator crosses zero when the displaced price equals the current SMA — this is a neutral cycle position.

Visual Behavior

DPO appears as a jagged oscillating line below the price chart, centered at zero. It lacks the smooth momentum shape of RSI or MACD. Its key visual characteristic is that peaks and troughs appear at regular intervals — these intervals are the cycle period you are measuring.


Section 2: Interpretation & Signals

Signal Zones

DPO Value Interpretation
Large positive extreme Price cycle peak — overbought relative to detrended baseline
Near zero Price at cycle midpoint — neutral
Large negative extreme Price cycle trough — oversold relative to detrended baseline
Consistent peak-to-peak distance Confirmed cycle period in that asset

Reading Cycle Length

The primary use of DPO is not entry/exit timing — it is cycle measurement. Count the number of bars between two consecutive DPO peaks (or two consecutive troughs). That distance is the dominant cycle period for that asset at that time.

Once you know the cycle is, say, 18 bars, you can project the next trough approximately 18 bars after the previous trough. Use DPO extremes as reference, not as mechanical signals.

Entry and Exit Rules

  • Oversold entry: DPO reaches its historical negative extreme (compare to recent troughs over 50+ bars) and begins reversing upward. Enter when DPO turns up from a new low.
  • Overbought exit: DPO reaches its historical positive extreme and begins turning down. Exit longs when DPO rolls over from a new high.
  • Neutral zone (near zero): Avoid initiating new positions here — price is at cycle midpoint with no directional edge.

Divergence

Bullish divergence: Price makes a new low, but DPO's trough is shallower than the previous trough. The cycle is weakening on the downside — potential reversal.

Bearish divergence: Price makes a new high, but DPO's peak is lower than the previous peak. Cycle momentum is weakening — potential top.

💡 TIP
DPO divergence is most reliable when the cycle has been consistent for at least 3 full oscillations on the chart. A single cycle is not enough history to establish "normal" extremes.

False Signals

⚠️ WARNING
DPO fails completely in strongly trending markets. When price is in a persistent directional move, the displaced price consistently stays above or below the SMA — DPO stays on one side of zero and never gives a reversal signal. Always check ADX before using DPO: ADX > 30 means DPO signals are unreliable.

Best Market Conditions

DPO works best in range-bound, cyclical markets — commodity futures with seasonal patterns, mean-reverting equity pairs, currency crosses with established oscillation ranges. It underperforms in momentum markets.

Chart Setup — DPO Cycle Identification

DPO Cycle Peak and Trough Identification


Section 3: Pass vs. Live — Real-Time Reliability

Moderate — the displaced close (N/2+1 bars ago) is a past value and does NOT change, but some platforms visually "center" DPO on historical bars, creating the appearance of future knowledge
Repaint Risk
Inherent — DPO uses a price from N/2+1 bars in the past
Lag
Wait for bar close — live bar's SMA component shifts until close
Confirmation Timing
Cycle period measurement and historical analysis of overbought/oversold extremes
Best Use
Real-time scalping entries — the displaced price introduces structural delay
Avoid

The repaint explanation: DPO's formula uses Close[N/2 + 1 bars ago]. This is a confirmed past price — it does not change. However, many charting libraries plot DPO "centered" on the bar that the displaced price corresponds to, which makes the DPO line appear to extend N/2+1 bars to the right of the actual calculation. This creates the visual illusion that the indicator is using future price data. It is not — the data is entirely backward-looking. The confusion arises from display centering, not from actual lookahead.

In live trading, the current bar's DPO value updates as the current SMA shifts with price movement. Once the bar closes, the DPO for that bar is final.


Section 4: Practical Use Cases

Setup: DPO(10) on 15m or 1H chart, combined with Bollinger Bands Signal: DPO at historical negative extreme AND price touches lower Bollinger Band Entry: DPO turns up from extreme low while price closes inside Bollinger Band Exit: DPO reaches near zero OR price reaches mid-Bollinger Band (SMA20) Key rule: Only use in consolidation phases — confirm range with ADX below 20

Real example: Gold futures in Q1 2024 showed a consistent 22-bar daily cycle measured by DPO(20). The DPO trough on January 17, 2024 (Gold at $2,002) projected a cycle trough approximately 22 bars later — which aligned with the March 8 low before the breakout to $2,185. Cycle projection gave an early positioning signal 6 weeks in advance.


Section 5: Pseudo Code

INPUT: close_prices[], period=20

PROCESS:
  Step 1: Calculate the displacement offset = floor(period / 2) + 1
  Step 2: Calculate SMA of close_prices with given period for each bar
            sma[i] = mean(close_prices[i - period + 1 : i + 1])
  Step 3: For each bar i where i >= (period - 1 + offset):
            displaced_close = close_prices[i - offset]
            dpo[i] = displaced_close - sma[i]
  Step 4: Bars before valid range = NaN

OUTPUT: dpo[] — oscillator values centered at zero in price units

EDGE CASES:
  - period must be >= 4 to produce a meaningful displacement
  - If close_prices length < period + offset: return all NaN
  - NaN in close_prices propagates through both SMA and displaced close
  - Period = 1: offset = 1, DPO = close[i-1] - close[i] (price change, not useful)

Section 6: Parameters & Optimization

Standard Period Conventions

Period Cycle Target Use Case
10 Short cycles (~2 weeks on daily) Short-term mean reversion, 1H charts
20 Medium cycles (~1 month on daily) Standard swing trading cycles
40 Longer cycles (~2 months on daily) Seasonal commodity patterns
60 Quarterly cycles Position trading, index seasonal analysis

Parameter Impact

Change Effect When to Apply
Decrease period Catches shorter cycles, more oscillations, more noise Active ranges, high-frequency mean reversion
Increase period Smooths shorter cycles out, reveals longer rhythm Commodity seasonality, weekly position trades
Use HL2 vs Close Minor smoothing effect on extreme readings No strong preference — Close is standard
What period should I use for S&P 500 daily cycles?

The S&P 500 has historically shown a 20-day (monthly) short cycle and a 40-day (bimonthly) medium cycle. Use DPO(20) to catch the shorter rhythm and DPO(40) for the longer one. When both align at an extreme — DPO(20) and DPO(40) both at trough simultaneously — the signal strength is higher.

How do I know if the cycle is real or random?

Measure at least 5 full DPO oscillations. If the peak-to-trough distances vary by less than 25%, the cycle is likely real. If the distances are erratic — one cycle at 8 bars, the next at 22 — there is no measurable cycle and DPO should not be used on that asset/timeframe.

Does DPO work on crypto?

Crypto markets have fewer measurable cycles due to high external shock frequency. On Bitcoin daily charts, a loose 20-30 day cycle exists in ranging periods, but breaks down during major news events. Use DPO on crypto only when price has been in a confirmed range for at least 60 days with ADX below 20.

Market-Specific Adjustments

  • Equity indices (SPX, QQQ): DPO(20) and DPO(40) — works well due to regular monthly options cycle effects
  • Commodity futures (Gold, Oil): DPO(40) to DPO(60) — seasonal and fundamental cycles are longer
  • Forex majors: DPO(20) on daily — central bank meeting cycles create observable rhythms
  • Crypto: Use cautiously — confirm range condition before applying

Section 7: Synergies & Conflicts

Works Well WithAvoid Combining With
Bollinger BandsBoth measure deviation from mean — DPO at extreme AND price at band outer edge = high-confidence mean reversion setup
ADXADX below 20 confirms ranging market where DPO cycle signals are valid
RSI(14)RSI divergence at the same bar as DPO extreme strengthens reversal case significantly
Cycle projectorsUse DPO-measured cycle length as input to project the NEXT extreme date
MACDMACD is trend-following — opposite philosophy to DPO cycle analysis. Conflicting signals cancel each other out
ADX above 30High ADX means DPO's cycle signals are structurally invalid in that regime
Simple Moving Average crossoversCrossovers lag into the trend DPO is specifically trying to remove

Section 8: Common Mistakes

Mistake Root Cause Solution
Using DPO in trending markets ADX > 30 — DPO stays on one side of zero permanently Check ADX < 20 before applying DPO
Treating DPO as a leading indicator Misunderstanding the displaced close as "lookahead" The displacement is backward — DPO is lagging, not leading
Trading the first DPO extreme without cycle history No baseline to judge what "extreme" means Need at least 5 oscillations to define normal extreme range
Ignoring cycle inconsistency Assuming cycles are constant when they drift Re-measure cycle length every 30 bars in active use
Mixing DPO period with a different SMA period on chart SMA(20) for entries and DPO(20) produce different reference points Use the same period for both if combining

Section 9: Cheat Sheet

ℹ️ INFO
**Detrended Price Oscillator (DPO)**

USE WHEN: ADX < 20 (ranging market), asset shows measurable cycle rhythm, 5+ consistent oscillations visible, commodity or index with seasonal patterns
AVOID WHEN: ADX > 25 (trending market), asset just broke major S/R level, news catalyst imminent, cycle length is erratic or unmeasurable

ENTRY SIGNAL: DPO at historical trough extreme AND beginning to turn upward — enter long. Reverse at peak extreme for short.
EXIT SIGNAL: DPO reaches midpoint (near zero) for quick exits, or DPO reaches opposite extreme for full cycle trades

PARAMETERS: Short cycles: DPO(10-20) | Medium cycles: DPO(20-40) | Seasonal: DPO(40-60)
CONFLUENCE: Bollinger Band outer touch + ADX < 20 + RSI at extreme = highest confidence setup

RISK: 60-70% of signals fail in trending markets — regime filter (ADX) is mandatory
BEST TIMEFRAME: Daily chart for cycle measurement; 4H for active swing entries within confirmed cycle