RSI is a technical metric based on recent historical performance that measures momentum and can help identify if a security is overbought or oversold.

There are 2 steps to calculate RSI. First we must calculate the Relative Strength of a security using historical performance.

Given N days,

Relative Strength = (Avg. of N day's Closes Up) / (Avg. of N day's Closes Down)

Then, we normalize the Relative Strength:

RSI = 100 - (100 / 1 + Relative Strength)

Convention states that when a stock has an RSI < 30 it is considered oversold; alternatively,  a RSI > 70 is generally considered overbought.