Momentum Indicators

ROC Indicator (Rate of Change): Formula, Signals, and MT5 Use

In this page: what ROC is, how it works, when to use it, a practical example with code, and a bonus tip.

๐Ÿ“– 7 min read

๐Ÿ“ 1,322 words

๐Ÿท๏ธ Momentum Indicators

ROC on a price chart: illustration of the indicator and how it is used in technical analysis
ROC โ€“ chart illustration

ROC (Rate of Change) Indicator Explanation

The Rate of Change (ROC) is a momentum oscillator that measures the percentage change in price over a specified period. Developed by technical analysts to identify momentum shifts and potential trend reversals, ROC compares the current price to a price from a specified number of periods ago and expresses the change as a percentage. The indicator oscillates around a zero line, with positive values indicating upward momentum and negative values indicating downward momentum. ROC is particularly effective for identifying momentum shifts, divergences, and overbought/oversold conditions through percentage change analysis.

How ROC Works: ROC is calculated by comparing the current closing price to a closing price from a specified number of periods ago and expressing the change as a percentage: ROC = ((Current Price - Price n Periods Ago) / Price n Periods Ago) ร— 100, where n is the lookback period (typically 12 or 25 periods). The result oscillates around zero, with positive values indicating that the current price is higher than the price n periods ago (upward momentum), and negative values indicating that the current price is lower (downward momentum). The magnitude of ROC indicates momentum strength: larger positive values indicate stronger upward momentum, while larger negative values indicate stronger downward momentum. ROC can also be calculated as a simple difference: ROC = Current Price - Price n Periods Ago.

When to Use ROC:

  • Momentum Shift Identification: ROC is highly effective at identifying momentum shifts when it crosses the zero line, providing clear entry and exit signals. A ROC crossing above zero indicates potential upward momentum, while a ROC crossing below zero indicates potential downward momentum. The zero line acts as a trend separator.
  • Divergence Analysis: ROC divergence occurs when price makes new highs or lows while ROC fails to confirm, often signaling potential trend reversals. Bullish divergence (price makes lower low, ROC makes higher low) suggests upward momentum building, while bearish divergence (price makes higher high, ROC makes lower high) suggests downward momentum building.
  • Overbought/Oversold Identification: Extremely high ROC values may indicate overbought conditions (strong upward momentum that may be exhausted), while extremely low ROC values may indicate oversold conditions (strong downward momentum that may be exhausted). However, ROC can remain in extreme territory during strong trends.

Advantages:

  • Provides clear, objective momentum signals through percentage change calculation, making it easy to interpret and implement in automated trading systems. The percentage format makes momentum strength comparable across different price levels.
  • Works effectively across multiple timeframes and asset classes, including stocks, forex, commodities, and cryptocurrencies. The indicator adapts well to different market conditions and price levels.
  • Helps identify momentum shifts early through zero line crossovers and divergence analysis, providing clear signals for entry and exit points. The simple calculation ensures reliability.

Limitations:

  • ROC can produce false signals in ranging markets when momentum oscillates around zero without clear directional movement, leading to whipsaws. The indicator works best in trending markets.
  • The indicator may lag behind price movements during rapid market changes, as it compares current price to a price from n periods ago. This lag can result in delayed entry and exit signals.
  • ROC does not account for price magnitude or volatility, only percentage change. Extremely high or low ROC values may not always indicate reversals, especially during strong trends.

In summary, ROC is a valuable momentum oscillator that provides clear percentage-based momentum signals, making it ideal for identifying momentum shifts and potential trend reversals. For comprehensive understanding, refer to technical analysis literature on rate of change indicators, Investopedia's ROC guide (opens in a new tab), TradingView's ROC documentation (opens in a new tab), and academic research on momentum oscillators in technical analysis published in journals such as the Journal of Financial Markets and the Review of Financial Studies.

Practical Example: Using the ROC Indicator in a Trading Strategy

The Rate of Change (ROC) is a momentum oscillator used to identify momentum shifts and potential trend reversals through percentage change analysis. In a trading strategy, the ROC indicator helps traders make entry and exit decisions based on momentum direction and zero line crossovers.

Scenario: You're creating a momentum-based strategy for Ethereum (ETH/USDT) on a 4-hour chart. You want to buy when ROC crosses above zero (indicating upward momentum) and sell when it crosses below zero (indicating downward momentum), assuming momentum will continue in the direction of the change.

Strategy Logic:

  • Calculate the ROC(12) using a 12-period lookback. The ROC oscillates around zero, with positive values indicating upward momentum and negative values indicating downward momentum. The zero line acts as a trend separator.
  • Buy signal: When ROC crosses above zero (shifting from negative to positive), indicating potential upward momentum and trend beginning.
  • Sell signal: When ROC crosses below zero (shifting from positive to negative), indicating potential downward momentum and trend reversal.

Backtrader Example:

python
import backtrader as bt

class ROCMomentumStrategy(bt.Strategy):
    params = dict(
        roc_period=12
    )
    
    def __init__(self):
        self.roc = bt.ind.ROC(period=self.p.roc_period)
        
    def next(self):
        if not self.position:
            # Buy when ROC crosses above zero (positive momentum)
            if (self.roc[0] > 0 and self.roc[-1] <= 0):
                self.buy()
        else:
            # Sell when ROC crosses below zero (negative momentum)
            if (self.roc[0] < 0 and self.roc[-1] >= 0):
                self.sell()

# Usage
cerebro = bt.Cerebro()
cerebro.addstrategy(ROCMomentumStrategy)

Expected Outcome: By using the ROC indicator, your strategy identifies momentum shifts through zero line crossovers, helping you enter trades when momentum is building and exit when momentum is weakening. This approach leads to better momentum-based entries, improved trend identification, and enhanced consistency by trading in the direction of momentum changes.

๐Ÿ’ก Bonus Tip

Consider using ROC divergence as a confirmation signal. When price makes a new high but ROC makes a lower high, it suggests weakening upward momentum and potential bearish reversal. This technique, documented in technical analysis literature, can significantly improve the accuracy of ROC-based trading strategies by identifying momentum shifts before price reversals occur.

Using the ROC indicator ensures your strategy captures momentum shifts effectively, improving entry and exit timing based on percentage change momentum analysis.

Build a ROC momentum EA for MT5

In the builder, ROC is the Momentum indicator in percent mode. The Strategy Builder has a Momentum / rate of change indicator with three settings: Length (default 10), Price (Close, under More settings) and Formula: difference (the default, raw price change), ratio or percent. With percent it is ROC.

The formula matters more than it looks. A percent value means about the same on EURUSD at 1.08 and on XAUUSD at 2400; a raw difference does not, so a threshold tuned on one symbol with the difference formula means nothing on another.

The zero rule, and why it whipsaws. The simplest build is Momentum is above 0 for buy and is below 0 for sell, on H1, with a Spread limit in Step 4 and an ATR-based stop. Expect a high trade count and a poor result from that plain version: in a range the line crosses zero again and again without price going anywhere, so the rule trades most in the conditions least able to pay the spread. Three fixes, tested one at a time:

  1. Distance, not sign: compare with a number away from zero and add Has been true for N bars in a row (2 bars).
  2. A trend filter: an EMA, buying only while price is above it. ROC can be positive inside a broad downtrend if the last N bars were up.
  3. Slope instead of level: is rising asks whether momentum is building, which fires earlier in a turn.

In hand-written MQL5. There is no built-in iROC function; the formula is one line, read on closed bars so it does not change while the current bar forms:

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

Use Every tick modelling in the Strategy Tester for the first run: "Open prices only" makes almost any momentum EA look better than it is.