Relative Strength Index (RSI)
collapse all in page
Syntax
index = rsindex(Data)
index = rsindex(___,Name,Value)
Description
Examples
collapse all
Calculate the Relative Strength Index for a Data Series for a Stock
Open Live Script
Load the file SimulatedStock.mat
, which provides a timetable (TMW
) for financial data for TMW stock.
load SimulatedStock.matindex = rsindex(TMW);plot(index.Time,index.RelativeStrengthIndex)title('Relative Strength Index for TMW')
Input Arguments
collapse all
Data
— Data with closing prices
matrix | table | timetable
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)
WindowSize
— Moving window size for relative strength index
14
(default) | positive integer
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
index
— Relative strength index
matrix | table | timetable
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
R2023a: fints
support removed for Data
input argument
fints
object support for the Data
input argument is removed.
R2022b: Support for negative price data
The Data
input accepts negative prices.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Contact your local office