RS_Index: Relative strength index

View source: R/Analyses_functions_2.R

RS_IndexR Documentation

Relative strength index

Description

This function computes the Relative Strength Index (RSI) for a time series.

Usage

RS_Index(X, period = 14, plot = FALSE, overbought = 70, oversold = 30)

Arguments

X

A vector.

period

Period length used for smoothing. Default is set to 14.

plot

Logical: If TRUE, the time series and the RSI are plotted (with overbought and oversold levels) in the same window in interactive sessions.

overbought

Horizontal line which indicates an overbought level in the RSI plot. Default is set to 70.

oversold

Horizontal line which indicates an oversold level in the RSI plot. Default is set to 30.

Details

To compute the RSI,

\text{RSI} = 100 \dfrac{\text{Average\_gain}}{\text{Average\_gain}+\text{Average\_loss}}

formula is used. Average gain and average loss are computed using the Wilders's smoothing method.

Value

A list or vector of the RSI values.

References

Wilder, J. W. (1978). New concepts in technical trading systems. Greensboro, NC.

Examples

X <- c(74.44,74.19,74.25,73.65,74.37,74.73,75.15,75.46,75.88,76.78,
            75.81,76.53,75.11,76.28,76.68,76.08,76.53,76.11,76.42,75.58,
            75.44,75.46,74.98)
RS_Index(X, plot = TRUE)


Rmfrac documentation built on Sept. 10, 2025, 10:31 a.m.