UPDATE: Complete rewrite of the code. Condensed for readability, with comments. New and improved description. Changed default settings. Corrected some calculation errors.
Overview:
The "ROCkin RSI" is a custom-built trading indicator designed to offer enhanced insight into market trends. This indicator combines elements of the Relative Strength Index (RSI) and Rate of Change (ROC) while also allowing for smoothing and a unique moving average overlay on the RSI value or its slope. The output is visualized through a colored histogram and an optional moving average line that changes color based on RSI levels (zones), both offering valuable perspectives on market conditions.
Key Components:
RSI: The Relative Strength Index is used to identify the momentum of a price trend over a certain length of time, as well as overbought or oversold conditions.
RSI ROC: Rate of Change applied to the RSI. It quantifies how quickly RSI is changing over a specified period.
Smoothing: A smoothed version of the RSI ROC is calculated to reduce noise and better identify prevailing trends.
RSI MA: This feature offers an optional moving average overlay that can be applied to either the RSI value or the RSI Slope (explained below). The color of this moving average changes based on pre-defined RSI zones, making it easier to gauge the momentum at a glance. This can allow traders to replace the standard RSI indicator with this more informative version that combines trend information with general RSI levels.
Here's how the moving average colors are set based on RSI levels:
When the RSI value is between 0 and 25, the color is light pink.
When the RSI value is between 25 and 45, the color is red.
When the RSI value is between 45 and 55, the color is yellow.
When the RSI value is between 55 and 75, the color is lime green.
When the RSI value is 75 or higher, the color is light green.
** These colors provide a visual indicator of the RSI level and can help in understanding the momentum as indicated by the RSI. The colors make it easier to see if the RSI is at a level where it typically might be considered to have strong upward momentum (lime green), strong downward momentum (red), or if it's more neutral (yellow). These are also commonly referred to as overbought and oversold conditions at the two extremes, which can help keep you from taking a trade that may turn around shortly after.
RSI Slope: The RSI Slope is essentially the difference between the current RSI value and its average over the ROC length, normalized by dividing by the ROC length. This measures how quickly the RSI is changing relative to its average value over a given period, providing a sense of the momentum or speed of the change in RSI.
Keep in mind that the RSI slope can be positive, negative, or zero:
- A positive slope indicates that the current RSI is greater than its average over the ROC length, suggesting increasing momentum.
- A negative slope indicates that the current RSI is less than its average over the ROC length, suggesting decreasing momentum.
- A zero slope would mean that the current RSI is equal to its average over the ROC length, indicating no change in momentum.
Settings:
**NOTE: Smaller values will allow for shorter trades while longer values will allow for holding through more volatility.
RSI Length: Affects the length of the RSI calculation. A shorter length will make the RSI more sensitive to price changes.
RSI Calculation MA Type: Allows you to choose the moving average type for the RSI calculation. Different MA types will alter the sensitivity and reaction time of the RSI.
RSI Rate of Change Length: Determines the length of the ROC applied to the RSI, affecting how responsive the indicator is to changes in RSI.
Smoothing Length: Adjusts how much the RSI ROC is smoothed. Higher values will result in smoother but less responsive lines. This is good for watching trends slowly grow and fade out, but will limit your ability to use it for entry and exit signals in a fast moving market.
RSI MA Length and Type: Settings for the optional RSI MA overlay. The length will affect how closely the MA follows the RSI, and the type will affect its sensitivity.
Use RSI or RSI Slope for MA?: Allows you to choose whether the MA is applied to the RSI value itself or its slope.
Potential Uses:
Trend Identification: The color of the histogram can indicate the market trend. A green histogram can be a bullish signal, while a red histogram can be bearish.
Overbought/Oversold: The RSI MA colors can be useful for identifying overbought or oversold conditions and changes in momentum.
Crossovers: Pay attention to when the RSI MA line crosses the histogram or vice versa, as it could be indicative of a changing trend.
Divergence: Watch how the histogram and moving average highs and lows from one to the next compare to the price, if the two are not in agreement, this can give you an indication of an incoming change of direction and a change in the trend of the price.