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.
Trading & investing are risky and many will lose money in connection with trading and investing activities. All content on this site is not intended to, and should not be, construed as financial advice. Decisions to buy, sell, hold or trade in securities, commodities and other investments involve risk and are best made based on the advice of qualified financial professionals. Past performance does not guarantee future results.
Hypothetical or Simulated performance results have certain limitations. Unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, including, but not limited to, lack of liquidity. Simulated trading programs in general are designed with the benefit of hindsight, and are based on historical information. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.
Testimonials appearing on this website may not be representative of other clients or customers and is not a guarantee of future performance or success.
As a provider of technical analysis tools and strategies, we do not have access to the personal trading accounts or brokerage statements of our customers. As a result, we have no reason to believe our customers perform better or worse than traders as a whole based on any content, tool, or platform feature we provide.
Charts used on this site are by TradingView in which the majority of our technical indicators are built on. TradingView® is a registered trademark of TradingView, Inc. www.TradingView.com TradingView® has no affiliation with the owner, developer, or provider of the Services described herein.
Market data is provided by CBOE, CME Group, BarChart, Massive, CoinAPI. Select U.S. equities data is provided through Massive. CBOE BZX real-time U.S. equities data is licensed from CBOE and provided through BarChart. Real-time futures data is licensed from CME Group and provided through BarChart. Select cryptocurrency data, including major coins, is provided through CoinAPI. All data is provided “as is” and should be verified independently for trading purposes.
This does not represent our full Disclaimer. Please read our full disclaimer.
© 2026 LuxAlgo Global, LLC.

