Log in to see Cloud of Tags

Wealth-Lab Wiki


public RSI(DataSeries ds, int period, string description) public static RSI Series(WealthLab.DataSeries ds, int period)

Parameter Description

ds The source DataSeries
period Indicator calculation period


The RSI function returns the Relative Strength Index indicator. RSI is one of the classic momentum indicators and was developed by Welles Wilder. RSI measures a market's internal strength by dividing the average of the sum of the up day closing prices by the the average of the sum of the down day closing prices over a specific period of time. It returns a value within the range of 0 to 100. The RSI is a leading or a coincidental indicator. Popular averaging periods for the RSI are 9, 14 and 25. Wilder used 14 periods. The indicator becomes more volatile and amplitude widens with fewer periods used.


  • The classic way to interpret RSI is to look for oversold levels below 30 and overbought levels above 70. These normally occur before the underlying price chart forms a top or a bottom. Note you should change the levels depending on market conditions. Ensure the level lines cut across the highest peaks and the lowest troughs. During strong trends the RSI may remain in overbought or oversold for extended periods.
  • RSI also often forms chart patterns which may not show on the underlying price chart, such as double tops and bottoms and trendlines. Also look for support or resistance on the RSI.
  • If underlying prices make a new high or low that isn't confirmed by the RSI this divergence can signal a price reversal. RSI divergences from price indicates very strong buy or sell signal.
  • Swing Failures. If the RSI makes a lower high followed buy a downside move below a previous low, then a Top Swing Failure has occurred. If the RSI makes a higher low followed buy a upside move above a previous high, then a Bottom Swing Failure has occurred.
  • The mid point level of 50 will often act as support or resistance if the RSI bounce off the 50 level. Crosses of the 50 level can be used as a buying or selling signal. When RSI cross above then buy, when RSI crosses below then sell.
  • RSI can be use to find dips in strong trends. Use trend indicator to determine a strong up trend then if the RSI is below 50, you have a dip in the up trend. In strong down trends use RSI above 50 to detect small rallies. Buy the dip and sell the small rally.


  • As a rule of thumb, allow RSI to stabilize for 2.5 to 3 times the specified Period. For example, start the trading loop at Bar Number 42 for a 14-period RSI.


RSI = 100 - ( 100 / ( 1 + RS ) )


RSI relative strength index
RS = (average of n bars' up closes) / (average of n bars' down closes)
n = number of bars or period, typically 14

Note in calculating the RS values for the total of closes up, add all price changes where the close is greater then previous close. For closes down, add all price changes where the close is less then previous close.

Finally, the RSI formula may be found in some technical references as the following equivalent expression:

RSI = 100 * UpDaysAvg / ( UpDaysAvg + DownDaysAvg )


using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators;

namespace WealthLab.Strategies { public class MyStrategy : WealthScript { // Thank you fundtimer public Color WS4ColorToNET( double WS4Color ) { return Color.FromArgb( (int)Math.Floor( ( WS4Color % 1000 ) / 100 * 28.4 ), (int)Math.Floor( ( WS4Color % 100 ) / 10 * 28.4 ), (int)Math.Floor( WS4Color % 10 * 28.4 ) ); } protected override void Execute() { // This script colors each bar based on the RSI oversold/overbought level DataSeries rsi = RSI.Series( Close, 14 ); double x = 0; double col = 0; // RSI is an "unstable" indicator; consult Language Guide for(int bar = 14*3; bar < Bars.Count; bar++) { x = rsibar; if( x > 50 ) { x -= 50; x *= 2; x /= 9; col = Math.Truncate( x ) * 100; } else { x = 50 - x; x *= 2; x /= 9; col = Math.Truncate( x ) * 10; } SetBarColor( bar, WS4ColorToNET(col) ); }

ChartPane RSIPane = CreatePane( 35, true, true ); SetPaneMinMax( RSIPane, 0, 100 ); PlotSeries( RSIPane, rsi, Color.Red, WealthLab.LineStyle.Solid, 1 ); } } }

Important Disclaimer: The information provided by Wealth-Lab is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security.  The owner of Wealth-Lab.com assumes no liability resulting from the use of the material contained herein for investment purposes. By using this web site, you agree to the terms of this disclaimer and our Terms of Use.

ScrewTurn Wiki. Some of the icons created by FamFamFam.