Skip to content

Free MT5 Expert Advisor

Hull MA Trend EA

MT5 Expert Advisor that trades slope changes of the Hull Moving Average, with an ATR stop-loss, R target and risk-% sizing.

Trendv1.0MetaTrader 5 (MQL5) Compiles with 0 errors Non-repainting signals Stop-loss on every trade
Strategy
Buys when the Hull Moving Average turns up after falling and sells when it turns down after rising, measured on closed bars. The stop is 2 x ATR and the target is 2R.
Risk model
1% of balance per trade (configurable), stop-loss on every order, one position at a time

What it does

The Hull Moving Average was designed to follow price closely while staying smooth. This EA uses the direction of its slope: when the Hull MA stops falling and starts rising, it buys; when it stops rising and starts falling, it sells.

Each order has an ATR-based stop-loss and a reward-to-risk target, and the position is sized from the stop distance.

How it works

The Hull MA is calculated inside the EA from closing prices:

  • WMA(n) is a linearly weighted average of the last n closes, with the newest close weighted most.
  • Raw value = 2 x WMA(n ÷ 2) - WMA(n). The Hull MA is the WMA of those raw values over the square root of n (rounded), which is 5 bars for the default of 21.
  • Buy: Hull MA on the last closed bar is higher than the bar before, while the bar before was at or below the one before that (a turn from down to up).
  • Sell: the mirror image.
  • Stop-loss: 2 x ATR(14). Take-profit: 2R.
  • Exit: with the default setting, a long closes as soon as the Hull MA slopes down on a closed bar (and a short when it slopes up).

How to use it

A Hull MA reacts faster than a standard moving average of the same length, so this EA gets in and out of trends earlier, at the cost of more signals. On EURUSD H1 the default period of 21 is a middle ground; longer periods such as 55 give fewer, slower trades.

Consider pairing the EA with your own higher-timeframe view: if you only enable it when the daily trend agrees, you remove many counter-trend turns.

Settings

InputDefaultWhat it changes
Hull MA period21Length of the Hull Moving Average.
Stop-loss distance (x ATR)2.0Stop distance as a multiple of ATR(14).
Take-profit (R multiple)2.0Target as a multiple of the stop distance.
Exit on slope turntrueCloses the trade when the Hull MA turns against it.
Risk per trade (% of balance)1.0Share of balance risked between entry and stop.
Fixed lots0Fixed volume instead of risk %; 0 = risk-based.
Maximum spread (points)20Skips signals when the spread is wider; 0 = off.
Trading start / end hour7 / 20Server-time window for new trades; equal values = 24 hours.
Move stop to break-eventrueStop to entry + 20 points once profit reaches 1R.
Use trailing stopfalseTrails the stop 2 x ATR behind price.
Magic number2611006Identifies this EA's trades.

Limitations

  • Slope changes happen often in sideways markets, so expect clusters of small losses.
  • The exit on slope turn can close winning trades on a single counter-bar.
  • There is no separate trend filter; every turn is traded in both directions.
  • The ATR stop does not consider nearby support or resistance.

Before you run it live

Test on a demo account and in the MetaTrader 5 Strategy Tester over several years first. No backtest results are published for this EA, and any test describes the past only.

  • Match the spread limit and trading hours to your broker's spreads, stop level and session times, and include commission and swap in tests.
  • Start with 1% risk or less and check the lot sizes in the Experts log; the Position Size Calculator is a useful cross-check.
  • Use a different magic number on each chart, and keep the terminal (or a VPS) running so stops are managed.

Test with and without the slope-turn exit, since it changes the trade profile much more than the period does.

Key inputs

Key inputs of Hull MA Trend EA
InputDefaultDescription
Hull MA period21Length of the Hull Moving Average.
Stop-loss distance (x ATR)2.0Stop distance as a multiple of ATR(14).
Take-profit (R multiple)2.0Target as a multiple of the stop distance.
Exit on slope turntrueCloses the trade when the Hull MA turns against it.
Risk per trade (% of balance)1.0Share of balance risked between entry and stop.

Educational tools, not advice. Automated trading can lose money quickly. Indicators and Expert Advisors describe price; they do not predict it, and past behaviour does not guarantee future results. Test everything on a demo account first and never risk money you cannot afford to lose. See our disclaimer.

Keep exploring

Related mt5 expert advisors