All posts · Expert Advisors · Trend following · Backtesting
Trend Following EAs: When They Work and When They Die
Why trend-following Expert Advisors that look great in backtests struggle live, and the regime, cost and correlation filters to build into one.
· 8 min read · Updated
Many trend-following Expert Advisors look great in backtests and then struggle live. If you've run a moving average crossover or a breakout EA through a choppy market, you've probably seen it happen.
Often the concept isn't the problem. Trend-following systems tend to struggle because they keep trading through the market conditions they're worst at. This post covers what those conditions are, and the filters you can code into an EA so it notices them.
This is educational content about how EAs are built and tested, not trading advice. Every rule and threshold below is an example to code and test, not a recommendation for your account.
Why trend following works, sometimes
Trend-following relies on one property of prices: during some periods, moves tend to continue (returns are positively autocorrelated). One common explanation is that information spreads gradually and market participants react at different speeds, so a move started by early movers is extended by later ones.
Whether a trend EA makes money comes down to a simple inequality:
Win rate × average win > loss rate × average loss + trading costs
Many trend systems win less often than they lose. Win rates below 50% are common for them, so any edge has to come from winners that are larger than losers. With a 40% win rate, the average win must be more than 1.5× the average loss just to break even before costs, and costs push that bar higher.
That's why optimizing a trend EA for win rate is a trap. A trend system with an unusually high backtest win rate deserves suspicion: often its exits have been tuned to the test period, which tends not to hold up live.
Regime detection: the missing piece
The most common mistake in trend EA development is treating the market as one unchanging environment. Markets move between trending and range-bound (mean-reverting) phases, and a trend EA can only expect to do well in the first.
A regime filter decides when the EA is allowed to trade. Here's a typical set of rules, as an example of what to code and then test:
ADX-based regime filter
- ADX above 25: trending, trend entries allowed
- ADX below 20: ranging, trend entries off
- ADX between 20 and 25: transitional, for example trade at reduced size or require extra confirmation
ADX alone is a blunt tool, so developers often add a second measure.
Hurst exponent
H > 0.5 persistent (trending) behavior
H ≈ 0.5 close to a random walk
H < 0.5 mean-reverting behaviorA rolling Hurst exponent over 100–200 bars gives a second opinion on whether recent price behavior is persistent. When it drops below 0.5, a trend EA has little reason to be trading.
Volatility band
Rank the current ATR against its own last 252 values (about a year of daily bars). Trend systems tend to struggle at both extremes: in very quiet markets you pay spread for noise, and in extreme volatility you get whipsawed. A common filter only allows trading while the ATR percentile sits in a middle band, for example between the 30th and 80th percentile. Test where your own strategy's band should be. Our post on using ATR properly covers percentile ranking in more detail.
Trading costs are bigger than they look
Spread and slippage are easy to underestimate in a backtest, and trend EAs are especially sensitive to them.
Take a hypothetical moving average crossover system on EUR/USD. The numbers are made up to show the arithmetic; they aren't results from a real system.
- Average win: 45 pips
- Average loss: 22 pips
- Win rate: 40%
- Spread: 0.8 pips
- Slippage: 0.5 pips on entry and 0.5 on exit
A round trip costs about 1.8 pips: one spread (you buy at the ask and sell at the bid) plus slippage on both sides.
Expectancy per trade:
- Before costs: (0.40 × 45) − (0.60 × 22) = 18 − 13.2 = 4.8 pips
- After costs: 4.8 − 1.8 = 3.0 pips
In this example, costs take more than a third of the edge, and that's with modest slippage. Around news or in thin markets, slippage of 2 pips per side is easily possible, which would push the cost to about 4.8 pips and wipe out the edge entirely.
What you can do about it
- Filter small targets. Skip signals whose expected move is small next to the round-trip cost, for example less than 10× costs.
- Trade higher timeframes. H4 and daily bars produce bigger average moves, so the same cost is a smaller share of each trade.
- Consider limit orders. A limit entry pays no slippage and can get a better price, at the cost of missing some trades. Test whether the trades you keep make up for the ones you miss.
Timeframe selection
Different timeframes suit different conditions. A rough guide:
M15–H1 (intraday trend following)
- Tends to do better: session opens (London, New York), strong directional days
- Tends to struggle: quiet sessions, pre-holiday trading, low-volume summer weeks
- Markets: liquid major FX pairs with tight spreads
- Signal examples: 20/50 EMA crossovers, breakouts of the first trading hour
H4–D1 (swing trend following)
- Tends to do better: established multi-week trends, after major policy decisions
- Tends to struggle: long consolidations, headline-driven back-and-forth markets
- Markets: major FX pairs, equity indices, commodities with clear fundamental drivers
- Costs: a smaller share of each trade
- Signal examples: Donchian channel breakouts, 50/200 EMA systems, multi-week high/low breaks
Weekly–monthly (position trend following)
- Tends to do better: multi-year macro shifts and long commodity cycles
- The catch: long, deep drawdowns while waiting for those moves, which needs a large account and patience
- Signal examples: Turtle-style breakout rules, 10/40-week moving average systems
Combining timeframes is a common filter: only take lower-timeframe entries in the direction of the higher-timeframe trend, and stand aside when they disagree.
Correlated positions: hidden concentration
A common setup: the same trend EA running on EUR/USD, GBP/USD, EUR/GBP and USD/CHF at the same time, on the idea that more pairs means more diversification.
Often it doesn't. When the US dollar is trending, those pairs tend to move together, so the four positions can behave like one trade at four times the size. When the trend turns, they can all hit their stops within minutes of each other.
One way to handle this in code is to scale a new position by its correlation with positions already open, measured over the last 20 days or so. For example:
- Correlation above 0.7: much smaller size, or skip the trade
- Correlation 0.4–0.7: reduced size
- Correlation below 0.4: normal size
The exact thresholds are yours to test. The point is that the EA should know what else is already open.
The parameter optimization trap
If optimization tells you that 17.3 is the perfect moving average period and 20 is not, be suspicious.
Over-optimized EAs are brittle and break as soon as the market stops looking like the test period. Ways to build something sturdier:
Prefer parameter plateaus. Look at results for neighboring values. If 15, 17 and 20 all work reasonably well, you've found something. If only 17.3 works, you've found noise. Round, widely used values such as 20, 50 or 200 also make results easier to compare with other research.
Keep data the optimizer never sees. It still happens that EAs are optimized on one stretch of history and deployed with no further testing. Split your data, for example:
- 60% for optimization (in-sample)
- 20% for validation (out-of-sample)
- 20% for a walk-forward test
If results drop sharply from in-sample to out-of-sample (a drop of more than about 20% is a common warning line), treat the system as overfitted.
Run a Monte Carlo test. Shuffle the order of your backtest trades 1,000+ times and look at the spread of drawdowns. If the 90th-percentile drawdown is far worse than the one in your original backtest, the backtest was helped by a lucky sequence of trades, and live trading may not be.
None of these tests can guarantee live results. What they do is make an overfitted system easier to spot before it costs money. The Strategy Tester guide covers the basics of running them in MetaTrader.
When trend EAs struggle: known danger zones
These are conditions where trend EAs commonly run into trouble, each with a filter you could code:
- Central bank policy reversals. When a central bank switches from hiking to cutting rates (or the reverse), established trends can reverse sharply. Filter idea: pause new entries for a period after policy meetings that change direction.
- Summer trading. Liquidity often thins out in the northern-hemisphere summer, ranges narrow and spreads can widen, which suits trend systems poorly. Filter idea: reduced size or a seasonal pause, unless you trade round-the-clock markets.
- Holidays. In the days before major holidays liquidity drops and prices can move erratically. Filter idea: a holiday calendar that stops new entries.
- Flash crashes. In a fast market, stop-loss orders can be filled far from their price. Filter idea: smaller positions, and guaranteed stops where your broker offers them.
- Very quiet markets. When volatility is near the bottom of its range, moves rarely extend far enough to pay for the losing trades. Filter idea: switch the EA off below a volatility percentile.
The part most traders miss
When trend-following EAs fail, it's often not because the idea stopped working, but because they kept trading through periods they were never built for.
An EA doesn't have to trade all the time. Building in switches that stand it aside is often worth more than another entry indicator:
- Volatility filter (for example, off when the ATR percentile is below 25 or above 80)
- Trend strength filter (for example, off when ADX is below 20)
- Correlation filter (limit how much correlated exposure can be open at once)
- Calendar filter (known low-liquidity periods and major events)
- Drawdown filter (for example, pause after a set number of consecutive losses or a drawdown limit)
Fewer, better-chosen trades with the costs fully counted are what you're aiming for, not more trades.
Checklist before running a trend EA
- Out-of-sample results hold up against in-sample results
- Monte Carlo analysis gives a realistic drawdown range
- Regime filters (ADX, Hurst, volatility) are implemented and tested
- Spread and slippage are modeled realistically
- Position sizing accounts for correlation between open positions
- Calendar filters cover known quiet or risky periods
- A maximum drawdown triggers an automatic stop
- The timeframe suits the current volatility
- You've considered limit orders instead of market orders
- You know when you'll step in manually (policy shifts, extreme events)
- It has run on a demo account before real money
A sturdy trend EA is less about clever indicators or the best-looking backtest, and more about solid risk controls and the discipline to sit out conditions that don't suit it.
The job isn't to make your EA trade more. It's to make it trade better.
Build a bot from your idea
Describe your trading idea and the AI writes MT4 or MT5 code for you to review and test, with a plain-English explanation and setup steps. Your first bot is free.