Main Content

rsindex

Relative Strength Index (RSI)

Description

example

index = rsindex(Data) calculates the Relative Strength Index (RSI) from the series of closing stock prices.

example

index = rsindex(___,Name,Value) adds optional name-value pair arguments.

Examples

collapse all

Load the file SimulatedStock.mat, which provides a timetable (TMW) for financial data for TMW stock.

load SimulatedStock.mat
index = rsindex(TMW);
plot(index.Time,index.RelativeStrengthIndex)
title('Relative Strength Index for TMW')

Input Arguments

collapse all

Data with closing prices, specified as a matrix, table, or timetable. For matrix input, Data is M-by-1 with closing prices. Timetables and tables with M rows must contain a variable named 'Close' (case insensitive).

Data Types: double | table | timetable

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: index = rsindex(TMW,'WindowSize',10)

Moving window size for relative strength index, specified as the comma-separated pair consisting of 'WindowSize' and a scalar positive integer.

Data Types: double

Output Arguments

collapse all

Relative strength index, returned with the same number of rows (M) and the same type (matrix, table, or timetable) as the input Data.

More About

collapse all

Relative Strength Index

Relative strength index is calculated by dividing the average of the gains by the average of the losses within a specified period.

RS = (average gains) / (average losses)

References

[1] Murphy, John J. Technical Analysis of the Futures Market. New York Institute of Finance, 1986, pp. 295–302.

Version History

Introduced before R2006a

expand all