Comment on page

# Momentum Indicator

**Syntax**:

`roc(period)`

**Arguments**:

`period`

- the length of period to use in the calculation

**Return**: A time series of values representing the rate of change for the input time series.

**Description**: The rate of change (ROC) is a momentum indicator that measures the proportional change in the input time series. It is calculated as the difference between the current value and a prior value, divided by the prior value.

**Example**:

roc_values = SPY.close -> roc(15)

**Definition**: Normalizes a time series based on the recent values.

**Syntax**:

`rsi(length)`

**Arguments**:

`length`

= the number of previous values to use in the calculation.**Return**: A time series of values, normalized to a range of +/- 100.

**Description**: Harmonization, or normalization, transforms data to enable operations, such as adding or averaging, on disparate time series (eg, asset prices).

**Example**:

normalized = SPY.close -> rsi(30)

**Definition**: Calculates the True Strength Index, which is a momentum indicator that uses double smoothing to reduce lag.

**Syntax**:

`tsi(shortLength, longLength, averageLength)`

**Arguments**:

`longLength`

: The number of previous values to use for the long trend line calculation.`shortLength`

: The number of previous values to use for the short trend line calculation.`avgLength`

: The number of previous values to use in the averaging calculation.

**Return**: Time series of true strength index values with a range of +/- 100.

**Description**: It is calculated by smoothing out the difference between two exponential moving averages of an asset's price and dividing it by the sum of the smoothed difference and a third exponential moving average.

**Example**:

tsiValues = SPY.close -> tsi(30, 90, 60)

**Definition**: Calculates the difference between the value of the current value of a time series and a previous value.

**Syntax**:

`mom(length)`

**Arguments**:

`length`

= number of values back used in the calculation**Return**: Time series of differences

**Description**: Market momentum can be used as a measure of market sentiment.

**Example**:

momValue = SPY.close -> mom(20)

**Name**: dx

**Definition**: Determines whether a current value is greater than, less than, or equal to a previous value. The resulting value is +1, -1, or 0, respectively, times a scale factor.

**Syntax**:

`dx(length, scale)`

**Arguments**:

`length`

: number of values back used in the calculation`scale`

: scale factor for values (default = 100)

**Return**: Time series of directional values

**Description**: Compares the current value to a previous value. The output value is +1, -1, or 0, if the current value is greater than, less than, or equal to the previous value, respectively, multiplied by a scale factor.

**Example**:

SPY.close -> dx(15)

SPY.close -> dx(50, scale=1.0)