RSI Divergence with Extreme Zone Filter By HaykTrading### Introduction
This indicator is a comprehensive RSI-based divergence detection tool designed to identify potential trend reversals and continuations. It monitors price action against the Relative Strength Index (RSI) to find discrepancies between momentum and price peaks or troughs.
### Originality and Unique Value
Unlike standard divergence scripts, this implementation includes a strict 'Zone Filtering' mechanism. A divergence signal is only validated if the preceding pivot point (the start of the divergence line) originated within defined extreme zones (typically above 70 or below 30). This ensures that only high-probability setups from overextended conditions are displayed, reducing the noise common in standard divergence indicators.
### Methodology
The script employs the following technical logic:
1. **Pivot Detection**: It utilizes a lookback period (5 bars) to identify Pivot Highs and Pivot Lows on both the RSI and the price chart.
2. **Divergence Logic**:
- **Regular Bullish**: Price forms a lower low while RSI forms a higher low.
- **Hidden Bullish**: Price forms a higher low while RSI forms a lower low.
- **Regular Bearish**: Price forms a higher high while RSI forms a lower high.
- **Hidden Bearish**: Price forms a lower high while RSI forms a higher high.
3. **Filtering**: The script checks if the 'Previous Pivot' value meets the user-defined limits (`limitUpper` and `limitLower`). If a bearish divergence starts below 70, or a bullish one starts above 30, it is filtered out.
4. **Visualization**: Uses `force_overlay = true` to synchronize drawing divergence lines on both the oscillator pane and the main price chart simultaneously for visual clarity.
### How to Use
- **Reversal Trading**: Regular divergences suggest that the current trend is losing momentum and a reversal may be imminent.
- **Trend Continuation**: Hidden divergences often suggest that the trend is likely to continue after a brief pullback.
- **Confluence**: Users should look for signals that occur near key support/resistance levels or use the integrated RSI Moving Average to confirm current momentum direction.
### Settings
- **RSI Settings**: Adjust length and source for the oscillator calculation.
- **Moving Average**: Choose from SMA, EMA, WMA, or VWMA to smooth the RSI line.
- **Divergence Toggles**: Individually enable or disable Regular and Hidden signals.
- **Zone Filters**: Define the 'Start Limit' levels to refine the quality of detected pivots.
### Disclaimer
Past performance does not guarantee future results. Divergences can persist for long periods in strong trending markets. Always use appropriate risk management and combine these signals with other forms of technical or fundamental analysis.
Indicador Pine Script®






















