ROC Momentum EA MT5 — No Code

ROC is not a builder indicator yet: the zero-line theory, how to code it in MQL5, and the closest no-code alternative with the supported Momentum indicator.

📖 8 min read

📝 1,456 words

🏷️ MQL5 and Expert Advisors

Share this article:

ROC Momentum EA for MT5 — No Code

The Rate of Change indicator answers one question: is price higher or lower than it was N bars ago, and by what percentage? That makes it one of the simplest momentum rules to reason about — and, as this guide will show, ROC is not one of the indicators AlfaTactix can currently export as working MQL5.

Theory first, if you need it: ROC indicator guide.

Can I build a ROC EA for MT5 without coding?

Not in AlfaTactix today. ROC has a form in the Strategy Builder UI, but it is not among the 13 indicators the MQL5 code generator actually supports — a Step 3 ROC condition does not produce a working .mq5 file. Two honest paths:

  1. Code the ROC formula in MQL5 — a short calculation over the close price, then a zero-cross or threshold check (outline below).
  2. Build the closest no-code equivalent with Momentum — one of the 13 supported indicators, measuring the same idea (change over N bars) in raw price units instead of a normalised percentage.

Disclosure: Educational guide — not financial advice.


Tactix AI on this workflow

AlfaTactix includes Tactix AI: use Tactix Studio to describe your idea in plain language and draft timeframes, signals, filters, and risk into the same six-step Strategy Builder form — or open Tactix Guide on any step when you only need a field explained. Review every value, then export MQL5 or Pine Script from Code Generator (form-first — not untested prompt-to-code).

What the ROC zero line actually tells you

ROC is calculated as:

text
ROC = ((Close[0] - Close[N]) / Close[N]) * 100

So with Length 10 on H1, a ROC of +0.8 means price is 0.8% higher than it was ten hours ago. Three consequences matter for an EA:

  • Zero is the only meaningful fixed level. Above zero, price is higher than N bars ago; below zero, lower. Unlike RSI there is no natural 70/30 — ROC has no bounded range, so "overbought" is symbol-specific.
  • It is normalised, so it travels. Because the output is a percentage, a ROC threshold means roughly the same thing on EURUSD at 1.08 and on XAUUSD at 2400. Momentum, which returns raw price difference, does not have that property — a Momentum threshold tuned on EURUSD will not mean the same thing on XAUUSD.
  • It says nothing about direction of trend, only about change. ROC (and Momentum) can be positive while price is in a broad downtrend, if the last N bars happened to be up.

That last point is the whole reason a bare zero-cross rule disappoints, and we come back to it below.

ROC in MQL5

There is no built-in iROC function in MQL5; the calculation is short enough to write inline:

double roc = ((close[0] - close[N]) / close[N]) * 100.0;
bool buy  = roc > 0;
bool sell = roc < 0;

Read close[] on closed bars only (CopyClose or the close[] series with a shift of at least 1), so the value does not change while the current bar is still forming. Smoothing (an EMA or SMA over the ROC series) reduces the zero-line flicker discussed below, at the cost of a small lag.

A No-Code Alternative With Momentum

The MT5 form supports Momentum with the same rich condition scaffolding this article originally described for ROC — compare, breakout, slope, divergence and pattern conditions, with Length, Source, Smoothing and Offset parameters. The math is different (raw price difference, not a percentage), but the buildable rule is the same shape:

  • compare: Momentum > 0 for buy, Momentum < 0 for sell — the zero-cross rule.
  • breakout: fires when Momentum pushes through a Threshold, with a Confirmation bar count — filters the small oscillations around zero.
  • slope: asks whether Momentum is rising, not whether it is positive — catches acceleration a level check misses.

Honest limit: because Momentum is not normalised, a threshold tuned on one symbol will not transfer to another the way a ROC percentage would. Re-tune Length and any threshold per symbol.

Build the Momentum EA step by step

Step 1 — Strategy Info. Name: Momentum H1 EURUSD. Give it a name you will still recognise after ten variations; the Strategy Tester report only shows the name.

Step 2 — Timeframes. H1 for a first build. Momentum on M1 or M5 produces a signal count that is dominated by spread rather than momentum.

Step 3 — Entry Signals. Add Momentum. Parameters: Length 10, Source Close, Smoothing EMA, Smoothing Length 5.

  • Buy condition: type compare, Operator >, Value 0
  • Sell condition: type compare, Operator <, Value 0

Step 4 — Market Filters. Add a liquidity (spread) filter. Momentum entries cluster around the moments when spread widens, and an EA that ignores spread will show a backtest that live trading does not reproduce. A market session filter helps too — see market filters.

Step 5 — Risk Management. Fixed fractional sizing, one stop, one target. An ATR-based stop suits Momentum better than a fixed pip stop, because signals arrive in both quiet and volatile conditions; see ATR and EA risk management.

Step 6 — Summary. Read the JSON. Confirm the buy condition says operator > against value 0 and the sell says <. This is the step where a mis-set condition is cheap to fix; after export it is not.

Export, compile and backtest

Open Code Generator, select MQL5, export, and drop the .mq5 file into MQL5/Experts. Compile in MetaEditor (F7) — the generated code is standard MQL5 and should compile without edits. If it does not, see common MQL5 EA errors.

In the Strategy Tester use Every tick modelling for the first run. "Open prices only" will make almost any momentum EA look better than it is, because it hides the intrabar path. Full guide: backtest an EA in the MT5 Strategy Tester.

Expect a high trade count and an unimpressive equity curve from the plain zero-cross version. That is the correct result for this configuration, and the next section is why.

Why a raw zero cross whipsaws

Both ROC and Momentum oscillate around zero, and in a ranging market they cross zero repeatedly without price going anywhere. Each crossing is a signal, each signal is a spread payment, and the strategy pays the spread far more often than it captures a move.

The specific failure is that zero-cross frequency is highest exactly when the move size is smallest. In a strong trend the line stays on one side for a long time and produces few signals; in a chop it crosses constantly. So the rule generates its heaviest trading in the conditions least able to pay for it.

Three ways to address it, in order of how much they usually help:

  1. Require distance from zero, not just sign. Switch to the breakout condition with a Threshold and Confirmation 2. You enter later and less often, and skip the cluster of signals that live right on the zero line.
  2. Add a trend filter so the signal only trades with the larger move. Add an EMA on Step 3 and accept buys only while price is above it. This directly fixes the "positive inside a downtrend" problem from earlier.
  3. Use slope instead of level. The slope condition with Direction Up asks whether momentum is building, which fires earlier in a turn and is less tied to the zero line.

Test these one at a time. Changing three things at once and seeing a better curve tells you nothing about which change earned it.

Filters and risk controls

Momentum-style rules are unusually sensitive to execution cost, so the filters matter more here than in a slower strategy:

  • Liquidity (spread) — non-negotiable for this strategy, as above.
  • Market session — behaves differently in the London and Asian sessions; restricting to one makes results far more interpretable. See market filters.
  • ATR volatility — keeps the EA out of dead markets where the zero line is crossed by noise alone.

On risk: size from account percentage rather than fixed lots, and let the stop come from ATR rather than a round pip number. A strategy with many small trades is dominated by cost and sizing, not by signal quality.

Next steps

Run the plain compare version first so you have a baseline, then add one filter at a time and compare in the Strategy Tester. Related builds worth reading next:

Building the same idea for TradingView? The same Momentum indicator, condition types and Step 4 filters produce Pine Script v6 from Code Generator.

Frequently Asked Questions

Not in AlfaTactix today. ROC is not among the indicators the MT5 Strategy Builder supports for export, so a Step 3 ROC condition cannot generate working MQL5. You can code the ROC formula yourself in MQL5, or build the closest no-code equivalent with Momentum — one of the 13 supported indicators — which measures the same idea (change over N bars) without normalising it to a percentage.

They measure the same thing differently. Momentum is the price difference over N bars; ROC expresses that difference as a percentage of the older price. Because ROC is normalised it is comparable across symbols and price levels — Momentum, in raw price units, is not. That difference is why Momentum is the closest substitute, not an identical one.

Length 10 is a common starting value. Shorter lengths react sooner and produce more signals — and more false ones; longer lengths lag more but survive noise better. Pick the length in the Strategy Tester on your own symbol and timeframe rather than copying a number.

Zero is the neutral line for both ROC and Momentum — above it, price is higher than N bars ago. Requiring a threshold away from zero (the builder's breakout condition, with a Threshold and Confirmation) filters out the small oscillations around zero that cause most false entries, at the cost of entering later.

Yes, and it is usually the difference between a demo-only EA and one worth testing. Add a moving average on Step 3 and only take Momentum buy signals while price is above it, or use Step 4 market filters for session, ATR volatility and liquidity.

AlfaTactix is a no-code strategy builder for MetaTrader 5 (MQL5) and TradingView (Pine Script) traders who design and manage rule-based strategies.

Trading involves substantial risk of loss. AlfaTactix generates code from the rules you define and does not provide financial advice. Past or backtested performance does not guarantee future results.

© 2026 AlfaTactix. All rights reserved.