Choose the RSI period, commonly 14 periods
Calculate the change in price for each period
Separate gains and losses
Gain = positive price change, otherwise 0
Loss = absolute value of negative price change, otherwise 0
Compute the average gain over the chosen period
Compute the average loss over the chosen period
Calculate Relative Strength (RS) = Average Gain / Average Loss
Calculate RSI = 100 – [100 / (1 + RS)]
If Average Loss = 0, RSI = 100
If Average Gain = 0, RSI = 0
For subsequent periods, use smoothed averages
Smoothed Average Gain = [(Previous Average Gain × (Period – 1)) + Current Gain] / Period
Smoothed Average Loss = [(Previous Average Loss × (Period – 1)) + Current Loss] / Period
Recalculate RS and RSI for each new period
