RSI5_50 with Divergence

May 19, 2020

Static chart image
Signals
Oscillators
Divergences
Pivot Based (Retrospective)

The RSI5_50 with Divergence indicator is a dual-period Relative Strength Index strategy designed to identify high-probability entries by filtering short-term momentum divergences with long-term trend bias.

Usage

The script utilizes two RSI components: a short-term RSI (default 5 periods) and a long-term RSI (default 50 periods).

  • Buy Conditions: A long entry is triggered when the long-term RSI is above the 50 level and a bullish divergence (regular or hidden) is detected on the short-term RSI.
  • Pyramiding: If a long position is already active, the strategy can add to the existing position when the short-term RSI crosses above the 20 level.
  • Take Profit: The strategy manages exits through a tiered take-profit system based on the long-term RSI reaching specific overbought thresholds (60, 65, 70, and 75).
  • Exit Conditions: Positions are closed if the long-term RSI crosses below the 30 level or if the optional 8% stop loss is triggered.

Details

This tool implements both regular and hidden divergences based on pivot points. Regular bullish divergence occurs when the price makes a lower low but the RSI makes a higher low, suggesting a potential reversal. Hidden bullish divergence occurs when the price makes a higher low but the RSI makes a lower low, suggesting trend continuation. By requiring the long-term RSI to be above 50, the script ensures that these bullish signals are only traded during established uptrends.

Settings

General Settings

  • RSI Period: The lookback period for the short-term RSI used for divergence detection.
  • Long RSI Period: The lookback period for the long-term trend filter.
  • RSI Source: The price source used for calculations (default is Close).
  • Pivot Lookback Right/Left: Determines the number of bars required to confirm a pivot high or low.
  • Take Profit at RSI Level: The primary RSI threshold to trigger a 75% partial exit.
  • Stop Loss%: A toggle to enable a hard 8% stop loss rule from the average entry price.

Divergence Settings

  • Max/Min of Lookback Range: Sets the range (in bars) within which the script looks for previous pivots to form a divergence.
  • Plot Bull/Hidden Bull: Toggles the visibility of regular and hidden bullish divergence labels.
  • Plot Bear/Hidden Bear: Toggles the visibility of regular and hidden bearish divergence labels.

FAQ

How do I access RSI5_50 with Divergence?

You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.

Can I use this for shorting?

While the script visualizes bearish divergences, the built-in strategy logic is currently optimized for long-only entries using the long-term RSI trend filter.

What does the background color represent?

The background fill indicates the state of the long-term trend: a green background appears when the long-term RSI is above 50, while a red background appears when it is below 50.

Free access on the following platforms
tradingviewSymbolTradingView
Open in your browser

This in-app browser is not compatible with Get Access from the library.

Tap the menu (...) at the top of your screen and select "Open in Browser", "Open in Safari", or "Open in Chrome" to continue.

ninjatraderNinjaTrader
Open in your browser

This in-app browser is not compatible with Get Access from the library.

Tap the menu (...) at the top of your screen and select "Open in Browser", "Open in Safari", or "Open in Chrome" to continue.

metatrader4MetaTrader 4/5
Open in your browser

This in-app browser is not compatible with Get Access from the library.

Tap the menu (...) at the top of your screen and select "Open in Browser", "Open in Safari", or "Open in Chrome" to continue.

thinkorswimThinkorswim
Open in your browser

This in-app browser is not compatible with Get Access from the library.

Tap the menu (...) at the top of your screen and select "Open in Browser", "Open in Safari", or "Open in Chrome" to continue.

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.