hidden & regular rsi divergence
May 8, 2023

The hidden & regular rsi divergence indicator identifies trading opportunities by detecting regular and hidden divergences using two distinct degrees of Zigzag and RSI calculations. It visualizes these price-momentum discrepancies directly on the chart to assist in identifying potential trend reversals or continuations.
Usage
The indicator can be used to spot trend exhaustion (regular divergence) or trend strength (hidden divergence). By utilizing two "degrees" (Depth, Deviation, Backstep), users can monitor short-term and long-term market structures simultaneously.
- Regular Divergence (Type 1): Occurs when the Zigzag forms a higher high (bearish) or lower low (bullish), and the highest/lowest RSI within those legs forms a lower high or higher low.
- Regular Divergence (Type 2): Similar to Type 1, but requires the RSI values specifically at the Zigzag pivot points to also show divergence.
- Hidden Divergence: Occurs when the Zigzag forms a lower high (bearish) or higher low (bullish), but the RSI forms a higher high or lower low, suggesting a potential continuation of the primary trend.
- Background Shading: The script includes a range-based coloring feature. If the RSI is between 60-80, the background turns green (bullish range). If the RSI is between 20-40, it turns red (bearish range).
Details
The script uses the Zigzag indicator to define market legs and the RSI to measure momentum. For every identified Zigzag leg, the script scans the corresponding RSI values to find the peaks and troughs. The internal logic filters these points based on specific criteria (Logic 1 vs. Logic 2) and can further refine results using overbought (70) and oversold (30) levels.
Settings
General Settings
- Source: The price source used for RSI calculations.
- MA Type/Length: Settings for the moving average applied to the RSI.
ZigZag Settings (Degrees 1 & 2)
- Depth: The minimum number of bars without a higher high/lower low required to define a pivot.
- Deviation: The minimum percentage or point change required to create a new Zigzag leg.
- Backstep: The minimum number of bars between pivots.
- Show Zigzag: Toggles the visibility of the Zigzag lines on the chart.
Divergence Settings
- Level for HIDDEN Divergence: Sets the RSI threshold required to validate hidden signals.
- Overbought/Oversold: Defines the levels for the optional divergence filter.
- Use Filter: If enabled, only shows divergences where the RSI values exceed the OB/OS thresholds.
RSI & Background Shading
- RSI Length: The period for the RSI calculation.
- Bull/Bear Range: Defines the upper and lower bounds for the background color shading.
FAQ
How do I interpret the different Zigzag degrees? Degree 1 is typically configured for higher timeframes or macro movements (higher depth/deviation), while Degree 2 is for smaller, micro movements. This allows you to see how short-term momentum relates to long-term structure.
What is the difference between Logic 1 and Logic 2 for regular divergences? Logic 1 looks at the highest/lowest RSI values anywhere within the Zigzag legs. Logic 2 adds a stricter requirement that the RSI values specifically at the Zigzag peaks/troughs must also diverge.
How can I access this script? You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Free indicator
Get free access to this indicator on the platforms below.
Unlock the entire LuxAlgo Library
Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.