The RSI uses a two-part calculation that starts with the following formula:
RSI_{\text{step one}} = 100- \left[ \frac{100}{ 1 + \frac{\text{Average gain}}{\text{Average loss} }} \right]RSIstep one=100−[1+Average lossAverage gain100]
The average gain or loss used in this calculation is the average percentage gain or loss during a look-back period. The formula uses a positive value for the average loss.
https://1b8abdc275b29edbd340ef43c2f36cf1.safeframe.googlesyndication.com/safeframe/1-0-40/html/container.htmlPeriods with price losses are counted as zero in the calculations of average gain. Periods with price increases are counted as zero in the calculations of average loss.
The standard number of periods used to calculate the initial RSI value is 14. For example, imagine the market closed higher seven out of the past 14 days with an initial average gain of 1%. The remaining seven days all closed lower with an initial average loss of −0.8%.
The first calculation for the RSI would look like the following expanded calculation:
55.55 = 100 – \left [ \frac {100 }{ 1 + \frac{ \left ( \frac{ 1\% }{ 14 } \right) }{ \left( \frac{ 0.8\% }{ 14 } \right)} } \right ]55.55=100−⎣⎢⎡1+(140.8%)(141%)100⎦⎥⎤
Once there are 14 periods of data available, the second calculation can be done. Its purpose is to smooth the results so that the RSI only nears 100 or zero in a strongly trending market.
RSI_{\text{step two}} = 100 – \left [ \frac{ 100 }{ 1 + \frac{ \left ( \text{Previous Average Gain} \times 13 \right ) \ + \ \text{Current Gain} }{ \left ( \left ( \text{Previous Average Loss} \times 13 \right ) \ + \ \text{Current Loss} \right ) } } \right ]RSIstep two=100−[1+((Previous Average Loss×13) + Current Loss)(Previous Average Gain×13) + Current Gain100]