All indicators

RSI Overbought Oversold Divergence Strategy w/ Buy/Sell Signals

Oct 6, 2021

Static chart image
Volume BasedSignalsOscillatorsDivergencesMoving Averages

The RSI Overbought Oversold Divergence Strategy w/ Buy/Sell Signals indicator is a comprehensive backtesting tool designed to identify and trade bullish and hidden bullish divergences across multiple oscillators. It aims to provide traders with a rule-based approach to mean-reversion and trend-continuation entries by automating the detection of price-oscillator discrepancies.

Usage

The script is primarily used to backtest divergence-based strategies using the TradingView Strategy Tester. It visualizes bullish divergences (price makes a lower low while the oscillator makes a higher low) and hidden bullish divergences (price makes a higher low while the oscillator makes a lower low).

Users can select from five different oscillators to base their signals on: RSI, OBV, RVSI, MFI, and TRIX RSI. The strategy executes buy signals based on these detections and can be refined using various confirmation filters such as moving average breaks or oscillator crossovers.

Details

This script utilizes a multi-lookback pivot detection system, checking up to 30 different left-hand lookback periods to identify significant swing points. Unlike its "indicator" counterpart, this version is specifically optimized for the Strategy Tester, removing manual alerts in favor of automated strategy.entry and strategy.close commands.

The implementation includes advanced logic for:

  • Divergence Logic: Compares pivot lows of price against pivot lows of the selected oscillator within a user-defined lookback window.
  • Confirmation Filters: Includes a "price bounce" requirement and EMA filters to ensure signals occur within specific trend contexts or after a minimum price recovery.
  • Oscillator Flexibility: Supports volume-weighted oscillators like OBV and MFI alongside standard momentum oscillators like RSI.

Settings

Oscillator Settings

  • Select Oscillator: Choose between RSI, OBV, RVSI, MFI, or TRIX RSI.
  • Oscillator Source: The price source used for calculations (e.g., Close, Low, HLC3).
  • Oscillator Length: The lookback period for the primary oscillator calculation.
  • Oscillator Moving Average Length: The length of the signal line (EMA) applied to the oscillator.

Oscillator Divergence Settings

  • Min/Max Lookback Range: Defines the window in which the script searches for divergent pivots.
  • Pivot Lookback Left (1-30): Specific bars to the left required to identify a pivot point.
  • Plot Bullish/Hidden Bullish: Toggle the detection of regular or hidden divergence types.

Signal Delays & Filters

  • Confirmation Time (bars): Number of bars to wait before a signal is confirmed.
  • Enable Wait for EMA Break: Requires price to cross a specific EMA before triggering an entry.
  • Enable Oversold Limits: Filters signals to only show when the oscillator has recently visited oversold territory.
  • Only Long in Uptrend: Uses a long-term EMA (default 200) to filter for trend-aligned entries.

FAQ

How do I use this to automate trades? This script is a strategy, meaning it generates simulated trades in the Strategy Tester. You can connect it to automated trading bots using the "Strategy Order Fill" alert functionality in TradingView.

Which oscillator is best for divergences? This depends on the asset and timeframe. RSI is standard for momentum, while MFI or OBV can be more effective if you want to incorporate volume data into your divergence signals.

How do I get access to RSI Overbought Oversold Divergence Strategy w/ Buy/Sell Signals? 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.

TradingView
NinjaTrader
MetaTrader 4/5

Unlock the entire LuxAlgo Library

Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.