Skip to main content
ForexNews24
Trend-followingMQL5Intermediate

TrendRider EA: trading robot for MQL5

Author: M. Sokolova, algorithm developer

TrendRider EA is a trend-following advisor that automatically holds a position in the direction of a moving-average cross.

How the advisor works

The advisor encodes a simple rule: long while the fast EMA is above the slow one, short while it is below. The value of automation here is not sophistication but discipline: the EA executes each reversal mechanically, without the hesitation that would ruin a discretionary trader during an extended trend.

The flip side of automation is that the robot does exactly what it was programmed to do, including entering every false reversal in a range. For trend-following advisors this is the main source of losses: without a market-state filter the EA whipsaws on every moving-average cross inside a sideways range.

Parameters and metrics

Advisor parameters
ParameterValue
EMA fast / slow50 / 200
TimeframeH4
Trailing stopATR × 1.5
Risk per trade1%

Check on real data

The advisor's logic was run on real quotes without fitting parameters to history. The rule tested was "TrendRider: EMA(50/200) trend following":

  • Long while EMA(50) is above EMA(200).
  • Short while EMA(50) is below EMA(200).
  • Reversal on the moving-average cross — the robot is always aligned with the trend.
-4.9%
Return/year (CAGR)
9.4%
Max drawdown
-1.07
Sharpe ratio
25%
Winning trades
4
Trades in period
50%
Time in market
929598102105
AdvisorBuy and hold
Equity curve of the advisor's rule against passive buy-and-hold on the EUR/USD sample, 2025-06-16 — 2026-07-20. On this sample the advisor lagged buy-and-hold. This is a result on one instrument over one period — an illustration of the mechanic, not a promise of returns.
How to read this result
A live advisor would add the execution costs of a specific broker to this picture — spread and slippage that are absent from the model run. That is why, before a real account, any EA goes through a forward test on demo: only it reveals the actual execution.
From the authors' review
«A trend-following advisor wins not by being right often, but through asymmetry: small losses against large profits stretched out over time.»

Pros and cons

Pros
  • Mechanical discipline: holds the trend without emotion.
  • Simple logic that resists overfitting.
  • Transparently testable on history.
Cons
  • Loses money in ranges — reacts to every false cross.
  • Always in the market, accumulating costs on reversals.
  • Gives back part of the profit on the turn while the averages realign.

Pitfalls

TrendRider fails in a range: without a trend filter the advisor enters on every moving-average cross, and in a range there are dozens of them. The second common mistake when launching an EA is optimizing the moving-average periods against past data until the backtest looks pretty — on new data such curve-fitting almost always performs worse than the standard periods.

Who it suits

For traders automating trend-following logic on trending instruments who understand that the advisor must be paired with a range filter. Not suitable for ranging markets.

Related methodology

Methodology
Swing trading

Frequently asked questions

Why is automating this rule better than trading it by hand?

Discipline. A discretionary trader tends to close the position early or miss the reversal out of doubt; the advisor executes the rule without exceptions. It is this rigor, rather than any complexity of the logic, that usually provides the edge.

Why does the advisor lose money in a range?

It enters on every moving-average cross, and in a range the averages intertwine constantly. Without a market-state filter this turns into a series of losing reversals.

What does the backtest show?

The behavior of the rule on a real EUR/USD sample. On a trendless stretch a trend-following advisor predictably goes into the red — an illustration that it needs a trending market.

From research to application

In our Allocation product we implemented these algorithms with all the nuances covered across the portal.

Learn about Allocation