DivergenceRSI

Category: Indicators

The DivergenceRSI function in ProBuilder language is designed to identify and return signals of bullish and bearish divergences between a stock’s price and its Relative Strength Index (RSI). Divergences in this context suggest a potential reversal in the current price trend, making this function useful for technical analysis in trading strategies.

Syntax

DivergenceRSI[RSIperiod, LowRSIthreshold, HighRSIthreshold, Bars](price)
  • RSIperiod: The period over which the RSI is calculated. Default is 5.
  • LowRSIthreshold: The lower threshold of the RSI, indicating oversold conditions. Default is 30.
  • HighRSIthreshold: The upper threshold of the RSI, indicating overbought conditions. Default is 70.
  • Bars: The number of bars considered for detecting potential divergences. Default is 20.
  • price: The price data (e.g., close, open) used for the RSI calculation.

RSI Divergence Calculation

A bullish divergence occurs when the price records new lows while the RSI begins to rise, suggesting a potential upward reversal. Conversely, a bearish divergence happens when the price hits new highs while the RSI declines, indicating a possible downward reversal.

Return Values

  • Returns +1 (green histogram) if a bullish divergence is detected.
  • Returns -1 (red histogram) if a bearish divergence is detected.
  • Returns 0 if no divergence is detected.

Example

i = DivergenceRSI[5,30,70,20](close)
return i
style(histogram)

This example sets up the DivergenceRSI function with a 5-period RSI, thresholds at 30 (low) and 70 (high), and checks for divergences over the last 20 bars using the closing price. The result is displayed as a histogram.

Additional Information

When using the DivergenceRSI function, ensure that the RSI settings (period and thresholds) match any other RSI indicators on your charts to maintain consistency in your analysis. This function is particularly useful for identifying potential reversals in trend, which can be critical points for making trading decisions.

Related Instructions:

  • DivergenceCCI indicators
  • DivergenceMACD indicators
  • Logo Logo
    Loading...