Multi-Oscillator Divergence Strategy
Dec 29, 2019

The Multi-Oscillator Divergence Strategy indicator identifies bullish and bearish divergences across various popular oscillators to automate trading entries based on momentum shifts.
Usage
The tool is used to detect both regular and hidden divergences between price action and a selected oscillator. By identifying these discrepancies, traders can anticipate potential trend reversals or continuations. Users can select from several oscillator types including DPO, Momentum, MACD, RSI, and Stochastic to suit their specific trading style.
For example, a regular bullish divergence occurs when price makes a lower low but the oscillator makes a higher low, suggesting weakening bearish momentum. Conversely, a hidden bearish divergence occurs when price makes a lower high but the oscillator makes a higher high, suggesting a continuation of the downtrend.
The strategy component automates these findings by entering long positions on bullish signals and short positions on bearish signals.
Details
This script is a refactored strategy version of the classic divergence detection logic. It utilizes pivot points (highs and lows) to compare price extremes with oscillator extremes within a defined lookback range.
Key technical aspects include:
- Multi-Oscillator Support: Integrated logic for five distinct calculation methods (DPO, Momentum, MACD, RSI, Stoch).
- Pivot Logic: Uses left and right lookback variables to confirm peaks and troughs. Note that increasing the "Pivot Lookback Right" setting increases the lag of the signal but ensures more stable confirmation.
- Range Filtering: Users can define the minimum and maximum distance (in bars) between two pivots to filter out irrelevant price fluctuations.
Settings
Main Settings
- Moving Average Type: Selects the underlying oscillator (DPO, Momentum, MACD, RSI, or Stoch).
- LookBack Period: The primary length used for the oscillator calculations.
- Price Source: The price data used for calculations (e.g., Close, HL2).
- Pivot Lookback Right: The number of bars to the right of a pivot to confirm its high/low status. Lower values reduce lag but may increase repainting during confirmation.
- Pivot Lookback Left: The number of bars to the left of a pivot to confirm its high/low status.
- Max of Lookback Range: The maximum number of bars allowed between two pivots for a divergence to be valid.
- Min of Lookback Range: The minimum number of bars required between two pivots.
Visualization
- Plot Bullish / Hidden Bullish: Toggles the visibility and strategy execution for bullish signals.
- Plot Bearish / Hidden Bearish: Toggles the visibility and strategy execution for bearish signals.
Specific Oscillator Settings
- RMA of DPO Length: Only used when "DPO" is selected.
- Fast MACD: Only used when "MACD" is selected.
- %D: The smoothing period for the Stochastic oscillator.
FAQ
How do I use the different oscillator types?
You can switch the "Moving Average Type" in the settings menu. Each oscillator reacts differently to market volatility; for instance, RSI is often preferred for trending markets, while Stochastics can be effective in range-bound environments.
Why do the signals appear a few bars late?
Divergence detection relies on "Pivot Lookback Right" to confirm a peak or trough. The signal will appear on the chart once that confirmation period has passed.
How can I access Multi-Oscillator Divergence Strategy?
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.