All indicators

Divergence Backtester

Oct 26, 2022

Static chart image
Price Action BasedSignalsOscillatorsDivergencesPivot Based (Retrospective)

The Divergence Backtester indicator is a statistical analysis tool designed to track and quantify the historical success rate of various divergence states by monitoring subsequent pivot formations. It provides traders with objective data on how frequently specific divergence types lead to trend changes or continuations based on historical price action.

Usage

The indicator can be used to validate the reliability of divergence signals on any given timeframe or asset. By analyzing the relationship between price pivots and oscillator movement, the tool categorizes each state and logs the resulting market behavior.

  • Trend Validation: Use the table output to determine if "Bullish Divergence" actually leads to higher highs in the current market context.
  • Strategy Refinement: Identify which specific types of divergence (e.g., Hidden vs. Regular) have higher probabilities of success for a particular pair.
  • Visual Backtesting: The script draws zigzag lines and labels that identify divergence states (e.g., Bullish Continuation, Bearish Against Trend) to help visualize where signals occurred and their outcomes.

Details

The script functions by tracking each pivot sentiment and the state of the subsequent pivot. It utilizes a matrix-based approach to record the sequence of events following a divergence signal.

Key concepts include:

  • Pivot States: The tool monitors whether price makes a Higher High (HH), Higher Low (HL), Lower High (LH), or Lower Low (LL) after a divergence is identified.
  • Divergence Categorization: Signals are classified into categories such as Bullish/Bearish Continuation, Hidden Divergence, and Regular Divergence based on the interaction between the price and the selected oscillator.
  • Oscillator Integration: Users can toggle between various oscillators (RSI, CCI, MFI, etc.) to see which one provides the most accurate divergence signals for their specific strategy.

Settings

  • Zigzag Length: Adjusts the sensitivity of the pivot detection; higher values focus on long-term trends, while lower values capture minor fluctuations.
  • Oscillator Type: Selection of the underlying indicator used for divergence calculation (Options: RSI, CCI, CMO, COG, MFI, ROC).
  • Oscillator Length: The lookback period for the chosen oscillator.
  • History: Determines the depth of historical data analyzed for the backtest stats.
  • Draw Zigzag Supertrend: Toggles the visibility of the visual trend overlay.
  • Text Size: Adjusts the size of the labels and table text on the chart.

FAQ

How do I interpret the backtest table? The table counts how many times the market reached specific pivot states after a particular divergence occurred. If "Bullish Divergence" shows a high count for "Higher Highs," it indicates a historically strong reversal signal.

Which oscillator is best for this backtester? There is no single "best" oscillator; the tool is designed to help you discover which one (e.g., RSI vs. MFI) performs most reliably on the specific asset you are trading.

How do I access this tool? 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.