Method 1: Raw Slope Difference
In this method, we directly compare the raw slope values of the price and the RSI. The slope is calculated using the linear regression formula:
Slope = (N Σ(xy) - Σx Σy) / (N * Σ(x^2) - (Σx)^2)
where x represents the time variable, y represents the price or RSI values, and N is the number of data points. While this approach is simple, it has the drawback of producing very different slope values for price and RSI, making them difficult to compare directly.
The problem here, is the Differences between the two slopes are very big, so comparing them is complicated. to Solve this problem, I tried normalizing their values.
Method 2: Normalized Slope Difference
To address the limitations of the raw slope difference, we can normalize the slopes by dividing them by their respective current values:
Normalized Slope = Slope / Current Value
This helps bring the price and RSI slopes onto a more comparable scale. However, this method still suffers from difficulties in comparing the slopes directly, as they can still vary significantly.
Method 3: Ratio of Slopes
In this method, we calculate the ratio between the price slope and the RSI slope:
Ratio = Price Slope / RSI Slope
This can provide a more meaningful comparison between the two slopes, as it directly shows how the price slope relates to the RSI slope. Nonetheless, the ratio can still produce very different values for bullish and bearish divergences, which can be challenging to analyze
Method 4: Angle Difference
Another approach is to calculate the angle between the price and RSI slopes. This method involves converting the slopes into angles using the arctangent function:
Angle = atan(Slope) * (180 / π)
The angle difference between the two slopes can then be computed:
Angle Difference = |Price Angle - RSI Angle|
This method can provide more consistent values, typically ranging between 0 and 30 degrees. However, interpreting the resulting angles can still be challenging, as it is unclear how to distinguish between bullish and bearish divergences.
Conclusion
We have explored various methods for calculating and analyzing slope divergence, each with its unique advantages and limitations. In practice, we found that analyzing the curve of the indicator was challenging, and interpreting the values was not straightforward. As a result, we recommend using visual divergence analysis instead, as it provides a more intuitive and user-friendly way to identify divergences.