RSI | R Documentation |
Relative Strength Index
Description
The Relative Strength Index (RSI) calculates a ratio of the recent upwardprice movements to the absolute price movement. Developed by J. WellesWilder.
Usage
RSI(price, n = 14, maType, ...)
Arguments
price | Price series that is coercible to xts or matrix. |
n | Number of periods for moving averages. |
maType | Either:
|
... | Other arguments to be passed to the |
Details
The RSI calculation is RSI = 100 - 100 / ( 1 + RS )
, where RS
is the smoothed ratio of 'average' gains over 'average' losses. The'averages' aren't true averages, since they're divided by the value ofn
and not the number of periods in which there are gains/losses.
Value
A object of the same class as price
or a vector (iftry.xts
fails) containing the RSI values.
Note
The RSI is usually interpreted as an overbought/oversold (over 70 /below 30) indicator. Divergence with price may also be useful. For example,if price is making new highs/lows, but RSI is not, it could indicate areversal.
You can calculate a stochastic RSI by using the function stoch
on RSI values.
Author(s)
Joshua Ulrich
References
The following site(s) were used to code/document thisindicator:
Relative Strength Index:
https://www.fmlabs.com/reference/RSI.htm
https://www.metastock.com/Customer/Resources/TAAZ/?p=100
https://www.linnsoft.com/techind/relative-strength-index-rsi
https://school.stockcharts.com/doku.php?id=technical_indicators:relative_strength_index_rsi
Stochastic RSI:
https://www.fmlabs.com/reference/StochRSI.htm
https://school.stockcharts.com/doku.php?id=technical_indicators:stochrsi
See Also
See EMA
, SMA
, etc. for moving averageoptions; and note Warning section. See CMO
for a variation onRSI.
Examples
data(ttrc) price <- ttrc[,"Close"] # Default case rsi <- RSI(price) # Case of one 'maType' for both MAs rsiMA1 <- RSI(price, n=14, maType="WMA", wts=ttrc[,"Volume"]) # Case of two different 'maType's for both MAs rsiMA2 <- RSI(price, n=14, maType=list(maUp=list(EMA),maDown=list(WMA)))