Disclaimer: This article is for educational and informational purposes only. It does not constitute financial or investment advice. Trading forex and CFDs carries significant risk of loss. Past performance of any strategy — including backtests — does not guarantee future results. Never trade with money you cannot afford to lose.
What Is This Strategy?
The Detrended Cycle Pullback strategy is a pro-trend, cycle-timing pullback system built around the Detrended Price Oscillator (DPO) — a momentum tool that strips the underlying trend out of price so that its shorter-term rhythm becomes easier to read. Rather than trying to predict tops and bottoms in the raw price chart, this strategy uses the DPO to spot cyclical dips and rallies, then only acts on them when they line up with the direction of the larger trend. It is a trend-following approach with a timing filter, not a counter-trend or "reversal" system.
The DPO works by subtracting a horizontally displaced simple moving average (SMA) from the current closing price. Because the moving average is shifted back in time by roughly half its length, the calculation removes the slow drift of the market and leaves a cleaner oscillation that swings above and below a zero line. Deep negative swings tend to mark short-term troughs, while deep positive swings tend to mark short-term peaks. To decide how "deep" is deep enough to matter, the strategy scales its trigger band using the Average True Range (ATR), a common measure of volatility. This means the entry threshold adapts automatically to calm or fast markets instead of relying on a fixed distance.
As a learning tool, this strategy is well suited to traders who want to understand how oscillators, trend filters, and volatility-based risk controls can be combined into a single rules-based system. It is designed for trending market conditions, where pullbacks against the prevailing direction offer timing opportunities to rejoin the move. Think of this article as a strategy analysis — a way to study how the pieces fit together — rather than a shortcut to any particular outcome.
How It Works
The strategy evaluates its logic once per completed bar and holds at most one position at a time. Here is how the entry, exit, and risk logic works in plain English:
- Trend filter (direction): A slow Exponential Moving Average (EMA) — a moving average that weights recent prices more heavily — defines the higher-level trend. If price is above the EMA, only long (buy) setups are considered. If price is below the EMA, only short (sell) setups are considered.
- Cycle trigger (timing): The strategy tracks the current and previous DPO values. A band is calculated as
BandAtrMult × ATR, which flexes with volatility. - Long signal: The strategy signals a potential long when price is above the trend EMA, the previous DPO reading dipped below the negative band (a cyclical trough), and the DPO is now turning back up. In other words, it aims to buy a dip that is beginning to recover inside an uptrend.
- Short signal: The strategy signals a potential short when price is below the trend EMA, the previous DPO reading pushed above the positive band (a cyclical peak), and the DPO is now turning back down. This aims to sell a rally that is beginning to fade inside a downtrend.
- Initial stop-loss: When a trade opens, the stop is placed
SlAtrMult × ATRaway from entry. Because it is ATR-based, the stop is wider in volatile conditions and tighter in quiet ones. - Take-profit: A target is set
TpAtrMult × ATRaway from entry, giving the trade a defined reward objective relative to its risk. - Breakeven move: Once price advances by
BreakevenRmultiples of the initial risk (for example, +1R), the stop is moved to the entry price so the position no longer risks the original loss. - ATR trailing stop: After breakeven, the stop trails price by
TrailAtrMult × ATR. The stop is only ever tightened, never loosened, which helps lock in open gains if the move continues.
Because every calculation references the chart's active timeframe, the same logic runs consistently on whatever timeframe you attach it to.

Strategy Parameters
| Parameter | Default | Min | Max | Description |
|---|---|---|---|---|
| DpoPeriod | 20 | 10 | 40 | Length of the SMA used inside the Detrended Price Oscillator. Shorter values react faster to short cycles; longer values smooth them. |
| TrendEmaPeriod | 100 | 40 | 200 | Length of the slow trend EMA that defines whether only longs or only shorts are allowed. |
| AtrPeriod | 14 | 7 | 28 | Lookback for the ATR used to size the trigger band, stop, target, and trail. |
| BandAtrMult | 0.75 | 0.20 | 2.0 | Multiplier that sets how deep the DPO must swing (in ATRs) to count as a cyclical extreme. |
| SlAtrMult | 1.5 | 0.8 | 3.0 | Initial stop-loss distance, expressed as a multiple of ATR. |
| TpAtrMult | 2.5 | 1.0 | 5.0 | Take-profit distance, expressed as a multiple of ATR. |
| TrailAtrMult | 2.0 | 1.0 | 4.0 | Distance of the ATR trailing stop once the trade is in profit. |
| BreakevenR | 1.0 | 0.5 | 2.0 | Profit, in multiples of initial risk (R), at which the stop moves to breakeven. |
| Lots | 0.10 | 0.01 | 1.0 | Fixed position size in lots for each trade. |

Recommended Chart Settings
This strategy was designed to run on a single symbol and the chart's primary timeframe, with all indicator readings taken from that timeframe. A common starting point for studying oscillator-and-trend systems like this is a major forex pair (for example, EUR/USD) on an intraday timeframe such as H1 (1-hour), where trends are frequent enough to produce pullbacks yet noise is more manageable than on very low timeframes. That said, the DPO period, EMA period, and ATR-based multipliers all interact with the character of the instrument and timeframe you choose. Results will vary across different symbols, sessions, and market conditions, so treat any single configuration as a study baseline rather than a fixed recommendation.
How to Install on MetaTrader 5
- Download the .ex5 file from the link below.
- Copy it to your MT5
MQL5\Expertsfolder. - Restart MetaTrader 5 or refresh the Navigator panel.
- Drag the EA onto a chart matching the recommended symbol and timeframe.
- Configure the input parameters and enable Algo Trading.
What to Consider Before Using This EA
The main strength of the Detrended Cycle Pullback approach is discipline: it combines a clear trend filter, a volatility-adaptive timing trigger, and fully mechanical risk management. By only taking pullbacks in the direction of the trend, it avoids the common trap of fighting a strong move, and the ATR-scaled band means the same rules behave sensibly across calm and volatile periods. The breakeven-then-trail exit logic is a textbook way to cap losers while giving winners room to run.
There are also real limitations to understand. The DPO is a smoothed, displaced calculation, which means its signals can lag the actual turning point in price. In choppy or ranging markets, the trend EMA can flip direction repeatedly and pullback signals may resolve into false starts, producing a string of small losses. Strong trending markets that never pull back deeply enough to reach the band may generate few trades at all. Like any single-position, fixed-lot system, it does not adapt position size to account equity, and it does not include a news or session filter — so unexpected volatility events can still hit the stop. No indicator combination removes uncertainty; the DPO may indicate a cycle turn that price simply does not confirm.
Risk Management Tips
Sound risk management matters more than any single entry rule. As a general education-focused checklist:
- Risk a small, fixed fraction per trade. Many educational sources suggest keeping risk to roughly 1–2% of account equity on any one position, so a losing streak does not do lasting damage.
- Size positions to your stop, not the other way around. The default fixed lot size may represent very different risk on different symbols; adjust it so the ATR-based stop distance stays within your per-trade risk budget.
- Test on a demo account first. Run the strategy in a risk-free simulated environment long enough to understand its trade frequency, drawdown behavior, and how it feels to hold its positions before considering live capital.
- Understand drawdown. Every strategy experiences losing periods. Know the largest peak-to-trough decline you are willing to tolerate, and stop to reassess if you approach it.
- Keep expectations grounded. Backtests and demo results are learning tools, not forecasts. Markets change, and a configuration that worked historically may behave differently going forward.
Risk Warning
Trading foreign exchange, CFDs, and other leveraged financial instruments involves substantial risk of loss and is not suitable for all investors. The strategies and tools discussed on this page are provided for educational purposes only and do not constitute financial advice, investment recommendations, or solicitation to trade. Always consult a qualified financial adviser before making trading decisions. Past backtest performance is not indicative of future results.
Downloads
- Expert Advisor: DetrendedCyclePullback.ex5 (3 downloads)
- Source Code: DetrendedCyclePullback.mq5 (3 downloads)
- Documentation: DetrendedCyclePullback.pdf (2 downloads)