Moving Average Pullback Trend Follower MT4
- Experts
- Version: 2.1
- Updated: 25 September 2026
- Activations: 5
OVERVIEW
A trend-following EA that enters on pullbacks to a moving average. It confirms the pattern only after a bar has fully closed and enters on the next bar (no look-ahead), and exits with a trailing stop. Forex only (USDJPY and EURJPY recommended).
This EA trades in the direction of a trending moving average (MA). When the MA is rising (or falling) and price has pulled back to touch the MA, the EA enters in the direction of the established trend.
ENTRY LOGIC (based on fully closed bars only)
- The H4 bars are built by the EA itself, aligned to New York time (boundaries at 0/4/8/12/16/20 NY time), so the signal does not depend on your broker's server time. Daylight saving time is handled automatically.
- The MA on the most recently closed bar is rising over a configurable lookback period (slope filter)
- That closed bar's body stays above the MA and its low touched the MA
- Once confirmed, the EA enters at market immediately after the bar closes (near the next bar's open). Because the decision only uses fully closed bars, backtest behavior matches live behavior (no repainting, no look-ahead bias).
- The mirror image applies for downtrends (pullback sell)
- A session filter skips entries on bars that close at NY 4:00 and 20:00, hours when liquidity tends to be thin (it can be turned off in the inputs)
EXIT
Trailing stop. An initial stop loss (StopPips) is set on every entry. Once floating profit reaches TriggerPips, the stop trails the price at a distance of TrailPips and only moves in the favorable direction. There is no fixed take-profit, so winners can run in strong trends.
A gap guard also skips entry on bars where the price gap from the prior bar is too large.
KEY FEATURES
- Decisions are based only on fully closed bars: no repainting, no look-ahead bias, backtest results are achievable live
- H4 bars aligned to New York time, independent of broker server time (automatic DST handling)
- Trailing stop lets profits run when a trend extends
- Lot size is automatically normalized to your broker's min/max lot and lot step
- Stop levels are automatically adjusted to respect your broker's minimum stop distance
- Entries are skipped when free margin is insufficient
- Gap guard (MaxGapPips) avoids unfavorable entries after large price gaps
INPUT PARAMETERS
MAPeriod: Moving average period (number of EA-built H4 bars)
SlopeLookback: Bars back used to judge the MA's slope
StopPips: Initial stop loss distance (pips)
TriggerPips: Floating profit (pips) at which trailing starts
TrailPips: Trailing distance (pips)
Lots: Order volume
MagicNumber: Unique identifier for this EA instance
Slippage: Allowed slippage
MaxGapPips: Gap guard threshold (pips, 0 to disable)
UseSessionFilter: Skip entries on bars that close at NY 4:00 and 20:00
RECOMMENDED SETUP
- Symbols: USDJPY, EURJPY (attach to one chart of either)
- Recommended values: MAPeriod=200, SlopeLookback=15, StopPips=180, TriggerPips=100, TrailPips=75, UseSessionFilter=true
- Account: ECN-style broker with low spreads recommended
- Run it on a demo account first
EXAMPLE BACKTEST RESULTS (for reference)
Recommended values above, EA-built NY-aligned H4 bars, April 2024 to September 2026 (about 2.4 years, historical tick-data simulation). This is a starting point for your own testing, not a guarantee of future performance.
USDJPY: 33 trades, win rate 87.9%, total P/L +2,754 pips, PF 4.80, max DD 543 pips
EURJPY: 36 trades, win rate 88.9%, total P/L +2,586 pips, PF 4.56, max DD 415 pips
PF (Profit Factor) = Gross Profit / Gross Loss. Max DD is the largest peak-to-trough drop in cumulative pips during the test period. Both pairs were confirmed positive on both the in-sample training period and the out-of-sample test period. GBPJPY was also tested but excluded from the recommendation, as its test-period result was slightly negative.
PLEASE READ - LIMITS OF THESE RESULTS
- The parameters and the session filter setting were chosen from several candidates using the same test period. Results in other market conditions may be very different.
- Small sample: roughly 30-40 trades per pair. The high win rate is the result for this period and this setting.
- Backtests are simulations. Real spreads, slippage, swap and order rejections will differ.
- The backtest results referenced in this listing are not live trading records.
- Past performance does not guarantee future results.
- Forex trading involves a risk of loss of capital. Use this product at your own discretion and risk tolerance.
- Always test on a demo account before live trading.
REQUIREMENTS
- MetaTrader 4 (MQL4) / MetaTrader 5 (MQL5)
- Recommended: ECN-style broker with low spreads
- Recommended symbols: USDJPY, EURJPY
