Investment Studio > Expressions > Functions > Indicator > ROC

float array[*][2] roc(float array[*][2] dc, integer days)

Returns a two-column array containing dates (first column) and corresponding Rate Of Change (ROC) values (second column). Given n input rows in dc, n - days (or fewer) rows are returned.

dc is a two-column array containing dates (first column) and corresponding daily closes (second column). The array is assumed to be time-sorted, with earlier dates preceding later dates.

Automatic type conversion allows the use of date strings as arguments instead of explicit date values.

days sets the timescale of the ROC, i.e. the number of trading days over which each day's ROC is computed.

Interpretation

ROC is the ratio between price now and price trading days ago, expressed in percentage points:

  price(now) - price(now - days)
ROC = 100   ¾¾¾¾¾¾¾¾¾¾¾¾¾
  price(now - days)

This is essentially equivalent to MO, with the advantage of being independent of the absolute price level. ROC values can therefore be readily compared across different periods and assets.

A ROC chart basically tells you two things: if prices are rising (ROC > 0) or falling (ROC < 0) and how fast they are doing so (the larger the absolute value of ROC, the faster). If ROC is falling but still hasn't crossed into negative territory, prices are still rising, but at a declining rate. Since the rate must fall to zero before the price can start falling, peaks and troughs in ROC usually lead peaks and troughs in price. An impending trend reversal in price will therefore usually be presaged by a divergence between ROC and price (i.e. ROC and price will be moving in opposite directions).

When such a divergence appears, it's important to wait for confirmation from the price action (i.e. a peak in price after a peak in ROC, a trough in price after a trough in ROC) before triggering an actual buy or sell signal. It's also a good idea to keep track of the position of ROC peaks and troughs relative to the historical record: a peak occurring well above historical ROC levels (i.e. during a strong uptrend in price), or a trough occurring well below historical ROC levels (i.e. during a strong downtrend in price), can easily turn out to be a "breather" followed by a resumption of the trend.

A less sophisticated approach is simply to buy when ROC crosses above a certain threshold (determined from historical data) and sell when it crosses below a second threshold (ditto). When traders talk about "momentum investing", this is basically what they have in mind. Replacing the thresholds with a longer ROC yields another common system (buy when the short ROC crosses above the long ROC, sell when the short ROC crosses below the long ROC).

12 and 25 day ROCs became particularly popular for short and intermediate term trading after Gerald Appel and Fred Hitschler detailed their use in the book Stock Market Trading Systems, but there is really nothing special about these numbers. As always, the choice of time frame should be based on the trader's own time horizon.

For a real life example, consider IBM (NYSE:IBM) from January 1 to December 31, 2001:

The top chart shows daily prices in standard candlestick form and their EMA(9). The bottom chart shows the 9 day ROC in blue and its 9 day EMA in black (with gray fill-in). The EMA can be seen to introduce only a modest lag (1 or 2 days at most with respect to 0 crossings and peaks) while making the ROC much less erratic (for even more smoothing, see TRIX). In the top chart, the days marked in green are EMA(ROC) crossings from below of 3.2; the days marked in red are EMA(ROC) crossings from above of 3.

Note the divergences between EMA(ROC) and EMA(price), especially in January, May and September.

The following charts show the same asset and period with 12 day (red) and 25 day (blue) ROC crossovers:

It's evident from the chart in the middle that raw ROC crossovers can be quite erratic, especially in the absence of a clear price trend. The highlighted days in the top chart reflect the much more tractable crossovers of ROCs smoothed with EMAs of the same length.

Example

Assuming standard US date format settings,

=roc({{"1/1/1990", 100}, {"1/2/1990", 97}}, 1)

returns {{32875, -3}}. 32785 is the date code for 1/2/1990; -3 = 100 *((97 - 100) / 100) is the 1 day ROC on that date.

See also efi, ema, mo, si, trix.