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 Nested Trend Pullback strategy is a multi-scale, trend-continuation system built around a dual Exponential Moving Average (EMA) filter and a single-bar pullback candlestick pattern. An EMA is a moving average that weights recent prices more heavily than older ones, so it reacts faster to fresh direction than a simple average. What makes this approach unusual is that it derives a "higher timeframe" view without ever loading a second chart — it synthesizes a slower, coarse trend directly from the primary series you are trading.
The design draws its spirit from the classic Elder Triple-Screen idea: only take fine-scale entries in the direction of the coarse-scale tide. Here, the coarse tide is produced by decimation — sampling one closing price every few bars to construct a down-sampled proxy series. A fast and slow EMA on that proxy defines whether the broader market is drifting up or down, while the raw primary bars supply a precise, tactical entry trigger. The strategy is designed for trending or continuation-friendly markets, where price advances in legs punctuated by brief counter-trend pauses.
As a learning tool, the Nested Trend Pullback is well suited to traders who want to study how trend filtering and pullback timing interact. It is a clean example of "trade with the tide, enter on the ripple." It is not a scalping tool or a range-bound reversal system, and it is best treated as a framework for understanding multi-scale confirmation rather than a shortcut of any kind.
How It Works
The strategy operates in two layers: a coarse trend filter (the "tide") and a fine entry trigger (the "ripple"). It evaluates conditions once per closed bar to avoid acting on incomplete, still-forming price data.
Building the coarse trend (the tide):
- The strategy samples the primary closing prices at intervals of
GroupSizebars, building a compressed "higher-timeframe proxy" series. - A fast EMA (
HtfFast) and a slow EMA (HtfSlow) are calculated on that proxy series. - The tide is considered up when the fast EMA is above the slow EMA and the fast EMA is rising versus its prior coarse reading.
- The tide is considered down when the fast EMA is below the slow EMA and the fast EMA is falling.
- If neither condition is met, no trade is considered — the market is treated as directionless.
Timing the entry (the ripple):
- For a long setup, the tide must be up, the prior closed bar must be red (a one-bar pullback against the trend), and the current trigger bar must be green and close above the prior bar's high — signaling the pullback has resolved back with the trend.
- For a short setup, the tide must be down, the prior bar must be green, and the trigger bar must be red and close below the prior bar's low.
Stop-loss and take-profit logic:
- Risk distances are based on the Average True Range (ATR), an indicator that measures recent volatility. A larger ATR means wider stops to accommodate choppier conditions.
- The stop-loss is placed
StopMult× ATR away from the entry price. - The take-profit is set at the stop distance multiplied by
RewardRatio, producing a fixed reward-to-risk target. - Only one position per magic number is allowed at a time, and the trade is managed entirely by its stop-loss and take-profit — there is no discretionary exit.

Strategy Parameters
| Parameter | Default | Min | Max | Description |
|---|---|---|---|---|
| GroupSize | 6 | 2 | 24 | Decimation stride — how many primary bars to skip between each sample of the coarse proxy series. Larger values create a slower, broader tide. |
| HtfFast | 5 | 2 | 15 | Fast EMA period applied to the coarse proxy series. |
| HtfSlow | 12 | 5 | 40 | Slow EMA period on the coarse series; must be longer than the fast EMA to define the trend. |
| AtrPeriod | 14 | 5 | 40 | Lookback period for the ATR used to size stop-loss and take-profit distances. |
| StopMult | 1.6 | 0.5 | 4.0 | ATR multiple that sets the stop-loss distance from entry. |
| RewardRatio | 1.8 | 0.5 | 5.0 | Reward-to-risk ratio; the take-profit distance is the stop distance multiplied by this value. |
| Lots | 0.10 | 0.01 | 1.0 | Fixed trade volume in lots for each position. |

Recommended Chart Settings
The Nested Trend Pullback is designed to run on a single primary timeframe, since it synthesizes its higher-timeframe view internally through decimation. This makes it adaptable: because the coarse proxy adjusts to whatever primary timeframe you select, the same logic can be studied on an H1 (1-hour) chart on a major currency pair such as EUR/USD as a sensible starting point for learning.
Higher timeframes like H1 and H4 tend to produce cleaner pullback structures and fewer false signals than very low timeframes, where noise dominates. That said, market behavior differs across instruments and sessions, and results will vary across different market conditions. Always test any configuration on historical data and a demo account before drawing conclusions about how it behaves.
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 Nested Trend Pullback lies in its layered filtering. By requiring both a directional tide and a resolved pullback before entering, it aims to filter out much of the chop that catches simple breakout systems. The decimation approach is also elegant: it approximates a higher-timeframe trend filter without the synchronization headaches of pulling data from multiple charts, and it scales automatically with whatever timeframe you apply it to.
However, this design carries the known limitations of all trend-continuation systems. In ranging or sideways markets, the fast and slow EMAs on the coarse series will cross back and forth, and pullback triggers may fire into moves that immediately reverse — historically a weak environment for continuation logic. The one-bar pullback definition is deliberately strict, which reduces false entries but can also cause the strategy to miss legs where the pause spans several bars rather than one.
Because exits rely solely on a fixed ATR-based stop and target, the strategy does not trail winners or scale out. In strong trends it may exit early relative to the full move, while in whipsaw conditions the ATR stop can be hit before the trend resumes. The GroupSize parameter also meaningfully changes the character of the tide — too small and the coarse view barely differs from the primary series; too large and it may lag well behind current price. Treat parameter tuning as a study in trade-offs, not a search for a single "best" number.
Risk Management Tips
Sound risk management matters far more than any single indicator setting. Consider these general principles as you study this strategy:
- Risk a small, fixed fraction per trade. A common guideline is to risk no more than 1–2% of account equity on any single position. Adjust the
Lotsvalue so your ATR-based stop distance aligns with that fraction. - Understand drawdown. Even a well-designed trend system can experience losing streaks. Know the maximum peak-to-trough decline you are willing to tolerate before you begin.
- Always start on a demo account. Run the EA in a simulated environment first to observe how it behaves across different market conditions before considering any live capital.
- Account for costs. Spreads, commissions, and slippage all affect real outcomes and are often understated in idealized backtests.
- Avoid over-optimization. Parameters that fit historical data perfectly frequently fail on new data. Favor robust, sensible settings over curve-fit extremes.
Treat this Expert Advisor as an educational framework for understanding multi-scale trend confirmation — not as a substitute for disciplined risk control and your own independent judgment.
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: NestedTrendPullback.ex5 (10 downloads)
- Source Code: NestedTrendPullback.mq5 (10 downloads)
- Documentation: NestedTrendPullback.pdf (15 downloads)