Learn R Programming

TTR (version 0.13-1)

changes: Rate of Change / Momentum

Description

Calculate the (rate of) change of a series over n periods.

Usage

ROC(x, n = 1, type = c("discrete", "continuous"), na = NA)
  momentum(x, n = 1, na = NA)

Arguments

x
Price, volume, etc. series to use.
n
Number of periods to use.
type
Compounding type; either discrete (the default) or continuous.
na
How should periods prior to n be represented? Default is NA.

Value

  • ROC returns a vector containing the rate-of-change (or return) values. momentum returns a vector containing the differenced price series.

concept

returns

Details

The ROC indicator provides the percentage difference of a series over two observations, while the momentum indicator simply provides the difference.

Examples

Run this code
data(ttrc)
  roc <- ROC(ttrc[,"Close"])
  mom <- momentum(ttrc[,"Close"])

Run the code above in your browser using DataLab