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
Ilustratif — data sintetis, bukan kutipan langsung.
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 Take a moving average of price over N bars — that is the trend
- 2 Line the price up with the middle of that window, or don't — this is the choice
- 3 Subtract; what remains oscillates around zero
Tampilkan rumus & detail perhitungan
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.
Sinyal
Sinyal yang dapat di-backtest dari DPO — dan kondisi pasar yang cocok untuk masing-masing.
Divergence
Interpretasi manualCycle length estimate
Interpretasi manualDPO against its own average
Interpretasi manualImplementasi MT5
Apa yang benar-benar dihitung dan digambar MetaTrader 5 — acuan bagi setiap aturan di halaman ini.
Catatan platform
Bekerja paling baik / gunakan dengan hati-hati
Tidak ada indikator yang merupakan keunggulan universal. Inilah di mana DPO membantu — dan di mana ia menyesatkan.
Bekerja paling baik
- 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
Gunakan dengan hati-hati
- 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
Buat strategi DPO
Hubungkan sinyal ke aturan masuk dan keluar, lalu ekspor EA MT5 yang dapat dikompilasi — tanpa kode.
- One DPO node at 20 using the bundled formula, read on the last closed bar
- A constant of 0 for it to be crossed against, once upward and once downward
- A 50-period EMA compared against the Bid, feeding both directions
- Cross up while price is above the average → Close short, then Open Buy · SL 50 / TP 130
- Cross down while price is below it → Close long, then Open Sell, mirrored
Gabungkan DPO dengan indikator lain
Satu indikator jarang berdiri sendiri. Kombinasi ini menutupi titik buta DPO.
DPO + CCI
- DPO
- CCI
- And gate
No shipped template pairs them; add a CCI node beside the DPO node and gate on both.
Buka Builder →DPO + HMA
- DPO
- HMA
Both nodes exist in the palette; there is no shipped template combining them.
Buka Builder →DPO + ADX Wilder
- DPO
Nothing to wire — this is a note about reading sources, not a combination.
Buka Builder →DPO + Moving Average
- DPO
- Moving average
- And gate
This is the shipped template — a DPO node, a constant of zero and a 50-period EMA compared against price.
Buka Builder →Parameter
Nilai awal untuk divalidasi pada pasangan dan timeframe Anda sendiri — bukan pengaturan yang dijamin.
| Parameter | Default | Rentang uji yang disarankan | Fungsinya |
|---|---|---|---|
| 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. |
Preset awal
Contoh pasar
Di mana DPO bekerja, di mana ia gagal, dan bagaimana filter mengubah hasilnya.
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.
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.
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.
Artikel terkait
Glossary