Developed J. Welles Wilder, RSI is a technical momentum indicator that compares the magnitude of recent gains to recent losses in an attempt to determine overbought and oversold conditions of an asset. Specifically: RSI = 100 - 100/(1 + RS) where RS = Average of x days' up closes / Average of x days' down closes. An asset is deemed to be oversold once the RSI falls below the 30 level, meaning that it may be getting undervalued and is a good candidate for a uptick. RSI uses all the price changes that occur over a given period in order to derive the average price change.
This RSI calculation is based on 14 days, which is the default suggested by Wilder in his book, plus a 20 range (the distance between the middle line and the upper and lower threshold lines). Richard Tortoriello backtests a a much longer timeframe 28-week RSI in the excellent book 'Quantitative Strategies for Achieving Alpha'.