This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.


Relative Strength Index (RSI)


rsi = rsindex(closep,nperiods)
rsits = rsindex(tsobj,nperiods)
rsits = rsindex(tsobj,nperiods,'ParameterName',ParameterValue, ...)



Vector of closing prices.


(Optional) Number of periods. Default = 14.


Financial time series object.


rsi = rsindex(closep,nperiods) calculates the Relative Strength Index (RSI) from the closing price vector closep.

rsits = rsindex(tsobj,nperiods) calculates the RSI from the closing price series in the financial time series object tsobj. The object tsobj must contain at least the series Close, representing the closing prices. The output rsits is a financial time series object whose dates are the same as tsobj and whose data series name is RSI.

rsits = rsindex(tsobj,nperiods,'ParameterName',ParameterValue, ...) accepts a parameter name/parameter value pair as input. This pair specifies the name for the required data series if it is different from the expected default name. The valid parameter name is

CloseName: closing prices series name

The parameter value is the character vector that represents the valid parameter name.

  1. The relative strength factor is calculated by dividing the average of the gains by the average of the losses within a specified time period:

    RS = (average gains)/(average losses)

  2. The first value of RSI, RISI(1), is set as NaN to preserve the dimensions of CLOSEP.


collapse all

This example shows how to calculate the RSI for Disney stock and plot the results.

load disney.mat
dis_RSI = rsindex(dis);
title('Relative Strength Index for Disney')


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

Introduced before R2006a

Was this topic helpful?