RSI SMA (Relative Strength Index)¶
- class src.lib.analysis.methods.rsi_sma.RSI_SMA(name)¶
Bases:
src.lib.analysis.basic.Basic
,src.lib.analysis.arbitration.Arbitration
,src.lib.analysis.performance_simulation.PerformanceSimulation
,src.lib.analysis.report_analysis.ReportAnalysis
,src.lib.analysis.summary.Summary
- calc_RSI_SMA()¶
Calculate de RSI (Relative Strength Index) indicator. The RSI is based on the following steps:
\[RSI = 100 - \frac{100}{1 + RS}\]where:
\[RS = \frac{Average Gain}{Average Loss}\]The Gain and Loss are taken as the diffeenrce day-by-day from the Closing value. For example:
\[Gain = CloseValue_N - CloseValue_{N-1}\]where N is the value for any day, and N-1 for the previous ones.
This result is averaged over the last 14 entries (e.g. days), where both Exponential or Simple moving averages can be used. For this application the Simple Moving Average is used.
The result from the RSI is to be interpreted as:
RSI > 70 means overbought, so an indication for selling.
RSI < 30 measn oversold, so an indication for buying.
However the RSI needs a more careful analysis, as informed by Investopedia:
During trends, the RSI readings may fall into a band or range. During an uptrend, the RSI tends to stay above 30 and should frequently hit 70. During a downtrend, it is rare to see the RSI exceed 70, and the indicator frequently hits 30 or below. These guidelines can help determine trend strength and spot potential reversals. For example, if the RSI can’t reach 70 on a number of consecutive price swings during an uptrend, but then drops below 30, the trend has weakened and could be reversing lower.
The opposite is true for a downtrend. If the downtrend is unable to reach 30 or below and then rallies above 70, that downtrend has weakened and could be reversing to the upside. Trend lines and moving averages are helpful tools to include when using the RSI in this way.
This analysis could be improved by the application of the histeresis in the method.