Personnalisés et communautaires CycleNot built inZero line Disponible dans Builder

DPO

Subtracts a moving average from price to strip the trend out and leave the cycle. Two conventions are in circulation and they are not variations of one indicator — measured, they correlate at −0.44, because the current price enters them with opposite signs. Not even the zero crossings port between them.

Default
20
Centre
0
Shift (textbook)
N/2 + 1
Bars where DPO turns up through zero in an uptrendzero — the two forms cross it together only 12% of the timeDPO(20) as MetaTrader ships it against the textbook form — they move against each other

Illustratif — données synthétiques, pas une cotation en direct.

What DPO tells you

A moving average is the trend; price minus that average is what is left once the trend is taken out. DPO is exactly that subtraction, and its purpose is to make the cycle visible without the drift underneath it. What turns it into a page of its own is that the subtraction is written two different ways. The textbook shifts the price back by half the period plus one before comparing it against an N-bar average — the shift exists to line the price up with the middle of the averaging window, which is where an N-bar average actually sits in time. The DPO.mq5 that ships with MetaTrader does not shift anything; it shortens the average to N/2+1 instead. Both are called DPO, both are plotted around zero, and measured on the same series they correlate at −0.44. The sign is not a typo: the current price pushes one of them up and the other one down, because in the textbook form today's price appears only inside the average being subtracted.

  • MetaTrader has no iDPO, but it does ship a DPO.mq5 — and that one does not shift
  • The two conventions correlate at −0.44: the current price enters them with opposite signs
  • Zero crossings agree only 12% of the time, so not even those port across
  1. 1 Take a moving average of price over N bars — that is the trend
  2. 2 Line the price up with the middle of that window, or don't — this is the choice
  3. 3 Subtract; what remains oscillates around zero
Afficher la formule et les détails de calcul

MetaTrader has no iDPO, but it does ship a DPO.mq5 under Indicators/Examples — and that file does not detrend the way the textbook does.

textbook : DPO[i] = price[i-(N/2+1)] - SMA(price, N)[i]        <- shifts the price back
bundled  : p = N/2+1 ; DPO[i] = price[i] - SMA(price, p)[i]    <- shifts nothing, shortens the average

At a period of 12 the textbook compares a 12-bar average against the price 7 bars ago; the bundled form compares a 7-bar average against the price right now. Measured over 4,000 bars on each of three series, the two correlate at −0.44.

The minus sign is the whole story. Bump one bar’s price by 1 and measure how far each reading moves:

                      predicted        measured
textbook   -1/N       -0.083333       -0.083333
bundled    (p-1)/p    +0.857143       +0.857143

In the textbook form today’s price appears only inside the average being subtracted, so raising it lowers the output. In the bundled form it is the leading term. One indicator treats the latest price as the signal; the other treats it as part of the trend to remove.

Not even the zero crossings port

On the ROC page the two competing formulas disagreed about every threshold but agreed on the sign 100% of the time, so a zero-cross rule moved between them untouched. That escape hatch is gone here:

              textbook    bundled    same bar
fx-flat         2829       2191        12.7%
fx-trend        2635       1736        12.2%
index-trend     2831       2117        12.4%

What the shift buys, and what it costs

Feeding in a known 20-bar sine wave buried in trend and noise, then searching for the lag that maximises correlation with the original wave:

             best correlation     phase lag
textbook          0.9957          -11 bars
bundled           0.9882           +2 bars

Both recover the cycle almost perfectly. Only one of them puts it under today’s candle. The textbook form’s lag is exactly its own N/2+1 shift — which is what makes its peaks line up with the cycles they belong to, and also what makes the last eleven bars of the line a description of the past. It is a measuring instrument, not a trigger. The template therefore reads the bundled form.

Both do remove the trend, which is worth stating since it is the indicator’s actual job: on a series whose price averaged 5414, the textbook DPO averaged −0.97 and the bundled one +1.94.

One measurement note. The first run of the warm-up test reported that the bundled form never matched a full-history baseline exactly. That was the instrument, not the subject: computing the average as a running sum makes the result depend on where the summation began, so two histories agree to about 1e-16 and never to the bit. Recomputing each window from scratch gave clean answers — exact from bar N−1 for the textbook form and p−1 for the bundled one, since neither has any recursion in it.

Signaux

Les signaux distincts et testables que génère DPO — et le régime adapté à chacun.

Zero cross

Prêt dans Builder
Condition
DPO crosses from below zero to above (mirrored for shorts)
Meilleur régime
Ranging
Utilisation typique
The template's entry — read on the bundled form, whose phase error measured 2 bars

Divergence

Interprétation manuelle
Condition
Price makes a new high while DPO does not
Meilleur régime
Ranging
Utilisation typique
Compares DPO against itself, so it needs no threshold — the one read that survives the choice of units

Cycle length estimate

Interprétation manuelle
Condition
The spacing between successive DPO peaks
Meilleur régime
Ranging
Utilisation typique
The classic use of the textbook form: measure the cycle after the fact, then set other indicators to it

DPO against its own average

Interprétation manuelle
Condition
DPO crosses a short moving average of itself
Meilleur régime
Either regime
Utilisation typique
A way to slow down a line that has no smoothing of its own

Implémentation MT5

Ce que MetaTrader 5 calcule et trace réellement — la référence de chaque règle de cette page.

Notes de plateforme

Fonctionne mieux / utiliser avec prudence

Aucun indicateur n'est un avantage universel. Voici où DPO aide — et où il induit en erreur.

Fonctionne mieux

  • Estimating how long a cycle runs, which is what the textbook form was built for
  • Ranging markets, where what is left after detrending is the tradable part
  • Divergences and other comparisons of DPO against itself, which need no fixed level
  • One instrument at a time — the readings are in that instrument's own units

Utiliser avec prudence

  • Fixed thresholds: DPO is a price difference, so 0.0015 means nothing on another symbol
  • The textbook form for live entries — measured, it lags in phase by its full shift of 11 bars
  • Assuming a DPO from another platform matches this one: the two conventions correlate at −0.44
  • Very short periods, where the average sits close to price and almost nothing is left over

Créer une stratégie DPO

Connectez le signal aux règles d'entrée et de sortie, puis exportez un EA MT5 compilable — sans code.

  1. One DPO node at 20 using the bundled formula, read on the last closed bar
  2. A constant of 0 for it to be crossed against, once upward and once downward
  3. A 50-period EMA compared against the Bid, feeding both directions
  4. Cross up while price is above the average → Close short, then Open Buy · SL 50 / TP 130
  5. Cross down while price is below it → Close long, then Open Sell, mirrored

Combiner DPO avec d'autres indicateurs

Un indicateur fonctionne rarement seul. Ces associations couvrent les angles morts de DPO.

DPO + CCI

  1. DPO
  2. CCI
  3. And gate
Pourquoi
The closest relative on this hub, and the comparison that shows what DPO leaves out. CCI also measures how far price sits from its own average, but it then divides by the mean deviation, which turns the reading into a scale-free number that can be compared across instruments and given fixed levels like ±100. DPO does not divide by anything, so it stays in the instrument's own units and no fixed threshold survives a change of symbol. What DPO gains in exchange is that its output is a price distance you can read directly — the same quantity your stop is denominated in
Meilleur régime
Ranging

No shipped template pairs them; add a CCI node beside the DPO node and gate on both.

Ouvrir Builder →

DPO + HMA

  1. DPO
  2. HMA
Pourquoi
Two different answers to the same complaint — that a moving average sits behind the market. Hull's answer is to build an average that catches up, by taking a weighted average of a weighted average and cancelling most of the lag arithmetically. The textbook DPO's answer is to leave the lag alone and move the price back to meet it, which is why the shift is N/2+1: that is where an N-bar window's centre actually is. The Hull line is something you can trade against in real time; the shifted DPO is something you read after the fact
Meilleur régime
Trending

Both nodes exist in the palette; there is no shipped template combining them.

Ouvrir Builder →

DPO + ADX Wilder

  1. DPO
Pourquoi
Not a signal pairing but the same trap in another place, and worth reading together. MetaTrader ships two ADX functions whose smoothing differs, and it ships a DPO whose formula differs from the textbook. In both cases the two versions carry the same name, both are plotted the same way, and the numbers underneath do not match. The lesson is identical: the name on the indicator does not tell you which formula is running, and the only way to know is to read the source and measure
Meilleur régime
Either regime

Nothing to wire — this is a note about reading sources, not a combination.

Ouvrir Builder →

DPO + Moving Average

  1. DPO
  2. Moving average
  3. And gate
Pourquoi
The template's pairing, and a slightly odd one on the face of it: DPO already contains a moving average, and the filter adds another. They do different jobs. The average inside DPO is the thing being subtracted — it defines what counts as trend and is thrown away. The 50-period average outside it is the thing being consulted — it decides which side of the cycle to take. Using one length for both would collapse the two questions into one and leave the rule with no view on direction
Meilleur régime
Trending

This is the shipped template — a DPO node, a constant of zero and a 50-period EMA compared against price.

Ouvrir Builder →

Paramètres

Valeurs de départ à valider sur votre propre paire et timeframe — pas des réglages garantis.

Paramètre Défaut Plage de test suggérée Ce que ça fait
Period 20 1–999 How long a trend has to be before it counts as trend rather than cycle. Everything shorter than this survives the subtraction; everything longer is removed. It also sets the shift in the textbook form, since that is derived as N/2+1 — so changing the period moves both the averaging window and how far back the price is taken from. A period near the cycle length you are trying to see is the usual starting point.
Formula shift the price (textbook) textbook / bundled Which of the two conventions to compute. `textbook` shifts the price back N/2+1 bars and subtracts an N-bar average; `bundled` shifts nothing and subtracts an N/2+1-bar average, reproducing the DPO.mq5 that ships with MetaTrader. Measured, they correlate at −0.44 — the current price carries a coefficient of −1/N in the first and (p−1)/p in the second, so it moves them in opposite directions. This is fixed when the EA is generated rather than exposed as an input, because switching it at runtime would not re-tune the strategy, it would invert it.
Applied price Close Close / Open / High / Low / Median / Typical / Weighted Which price series both halves of the subtraction are taken from. The same choice feeds the moving-average handle and the price being subtracted from it, so the two always agree — median, typical and weighted are assembled from the high, low and close when the EA is generated.
Shift 1 0–100 Which bar the reading is taken from. The template uses 1 so the crossing is judged on a closed bar. Note that this is a separate thing from the N/2+1 shift inside the textbook formula: that one is part of the definition and moves the price relative to the average, while this one moves which bar you read the finished value on.
Timeframe Current Current / M1–MN1 Which series is sampled. Warm-up is short and follows directly from the formula: measured against a full-history baseline, the textbook form is exact from bar N−1 and the bundled form from bar p−1, because there is no recursion anywhere for a truncated history to get wrong.

Préréglages de départ

Template 20, bundled formula, 50-period filter Zero crossings on the form whose phase error measured 2 bars
Cycle measurement Period near the cycle length, textbook formula The classic use — read the spacing between peaks after the fact
MetaTrader-bundled Any period, bundled formula Matches the DPO.mq5 under Indicators/Examples, if you are reproducing its chart

Exemples de marché

Où DPO fonctionne, où il échoue et comment un filtre change le résultat.

Fonctionne

The cycle low with the trend behind it

DPO turns up through zero while price is already above its 50-period average. The filter is what separates this from the identical-looking crossing a few bars earlier, which had no direction behind it.

Échoue

The crossing that came from the average, not the price

A flat stretch where the average drifts up into a static price and pushes DPO through zero from below. Nothing moved; the thing being subtracted did.

Filtré

The two conventions pointing opposite ways

A bar where the bundled form is clearly positive and the textbook form clearly negative. Measured, this is the normal state of affairs rather than an edge case — the two correlate at −0.44.

FAQ

Is DPO built into MetaTrader 5?
There is no iDPO function, so an EA cannot create a handle to it directly. The terminal does ship `DPO.mq5` under `Indicators/Examples`, so it appears in the Navigator and can be reached with iCustom. The Builder's node computes it from an `iMA` handle and the price series instead, which needs no external file.
Why does DPO shift the price backwards?
Because an N-bar average describes the middle of its window, not its right-hand edge. Moving the price back by N/2+1 lines the two up in time, which is what makes the leftover wiggle a cycle rather than a mixture of cycle and lag. The bundled MetaTrader version skips this and shortens the average instead.
Which formula should I use?
For measuring cycle length after the fact, the textbook form — that is what the shift is for. For a live rule, the bundled form, whose phase error measured 2 bars against a known 20-bar wave where the textbook form lagged by 11. What you should not do is tune on one and run the other: measured, they correlate at −0.44.
Do the two versions give different signals?
Yes, and more than ROC's two versions did. There, the sign always agreed so zero crossings ported across untouched. Here, measured upward zero crossings landed on the same bar only about 12% of the time, because today's price pushes the two readings in opposite directions.
What does a DPO of 0.0015 mean?
That price is 0.0015 above the detrended baseline, in the instrument's own units — 15 pips on a five-digit EURUSD. There is no normalisation in the formula, so the same number means something else on another symbol. If you want a comparable figure, CCI divides by the mean deviation to get one.
What period should I use?
Something near the cycle you are trying to see; 20 is the template's. The period decides what counts as trend — anything longer than it is subtracted away — and in the textbook form it also sets the shift, since that is N/2+1. Too short and the average tracks price so closely that almost nothing is left over.
How much history does DPO need?
N−1 bars for the textbook form and p−1 for the bundled one, and then it is exact. Measured against a full-history baseline, that came out at 11 and 6 for a period of 12. There is no recursion for a short history to get wrong.
Can DPO predict turning points?
It can describe them, which is not the same thing. The textbook form draws the cycle it has already seen, shifted back by N/2+1 bars, so its peaks line up with real ones only in hindsight. Anything predictive has to come from assuming the cycle repeats — which is an assumption about the market, not something the indicator supplies.
Can I build this without coding?
Yes. The template is one DPO node at period 20 on the bundled formula reading the closed bar, a constant of zero for it to cross, two Cross nodes for the two directions, a 50-period EMA with two Compare nodes against the Bid, two And gates, two Close nodes wired ahead of the entries, and Open Buy / Open Sell on a fixed lot. The compiled EA exposes the period, applied price, stop distances, lot size and maximum spread as inputs.

Glossary

Termes clés