Relative Strength Index (RSI)

View as Markdown

Description

Developed by J. Welles Wilder and introduced in his 1978 book, New Concepts in Technical Trading Systems, the Relative Strength Index (RSI) is an extremely useful and popular momentum oscillator. The RSI compares the magnitude of a stock’s recent gains to the magnitude of its recent losses and turns that information into a number that ranges from 0 to 100.

… Courtesy of StockCharts

The original Wilder formula for an exponential moving average with a smoothing constant (k = 1/ Period) is used to calculate the RSI.

Syntax

RSI(int period, int smooth)

RSI(ISeries\<double\> input, int period, int smooth)

Returns default value

RSI(int period, int smooth)[int barsAgo]

RSI[ISeries\<double\> input, int period, int smooth)[int barsAgo]

Returns avg value

RSI(int period, int smooth).Avg[int barsAgo]

RSI(ISeries\<double\> input, int period, int smooth).Avg[int barsAgo]

Return Value

double; Accessing this method via an index value [int barsAgo] returns the indicator value of the referenced bar.

Parameters

ParameterDescription
inputIndicator source data (Series<T>)
periodNumber of bars used in the calculation
smoothSmoothing period

Examples

1// Prints the current value of a 20 period RSI using default price type
2double value = RSI(20, 3)[0];
3Print("The current RSI value is " + value.ToString());
4
5// Prints the current value of a 20 period RSI using high price type
6double value = RSI(High, 20, 3)[0];
7Print("The current RSI value is " + value.ToString());

Source Code

You can view this indicator method source code by selecting the menu New > NinjaScript Editor > Indicators within the NinjaTrader Control Center window.