Introduction to Divergence in Technical Analysis
In the world of technical analysis, traders and analysts rely on various tools to predict market movements and identify potential trading opportunities. One such powerful concept is divergence, which occurs when the price action of an asset moves in the opposite direction to a technical indicator. This discrepancy often signals a weakening trend or an impending reversal, making it a valuable tool for spotting entry and exit points. Get this indicator now:Divergence detector from any input indicator’s plot on NinjaTrader 8.
Divergences are typically classified into two main types:
- Regular Divergence: This happens when the price makes higher highs (or lower lows) while the indicator fails to do so, indicating a potential trend reversal.
- Hidden Divergence: This is a continuation signal where the price makes a higher low (or lower high), but the indicator shows a lower low (or higher high), suggesting the trend may persist.
Common indicators used to detect divergences include the Relative Strength Index (RSI), Moving Average Convergence Divergence (MACD), Commodity Channel Index (CCI), and Stochastic Oscillator. Manually spotting these divergences can be time-consuming and prone to human error, which is where automated tools like the Divergence Detector Indicator come into play.
What is the Divergence Detector Indicator?
The Divergence Detector Indicator is a versatile tool designed specifically for the NinjaTrader 8 platform. Unlike standard divergence indicators that are tied to a single oscillator (e.g., RSI or MACD), this detector stands out for its flexibility—it can analyze divergence from any input indicator’s plot, as long as the plot provides a value on every bar. This makes it a “universal” divergence checker, allowing traders to apply it to custom or less common indicators.
Key features include:
- Detection of both regular and hidden divergences.
- Visual signals such as arrows or lines on the chart to highlight divergence points.
- Customizable parameters for swing length, which helps in identifying short-term to long-term divergences.
- Optional “Wait 1 Bar” confirmation to filter signals by checking trend direction on the next bar, reducing false positives.
- Integration with NinjaTrader’s Market Analyzer for scanning multiple instruments.
- Alerts for new divergence signals, enabling timely trading decisions.
This indicator is available as a permanent license, distinguishing it from time-limited versions of similar tools.
How the Divergence Detector Works
At its core, the indicator compares price swings (highs and lows) with the corresponding values from the selected input indicator’s plot. It identifies divergences by locating swing points—key highs and lows within a specified range—and checking if the indicator’s behavior aligns or diverges from the price.
Core Mechanism:
- Swing Point Identification: The tool uses a “swing length” parameter to define the lookback period for finding recent highs and lows. A shorter length (e.g., 5-10 bars) captures short-term divergences, while a longer one (e.g., 20-50 bars) focuses on broader trends.
- Divergence Check: For regular bullish divergence, it looks for lower lows in price but higher lows in the indicator. For bearish, higher highs in price but lower highs in the indicator. Hidden divergences reverse this logic for continuation signals.
- Signal Generation: Once a divergence is detected, the indicator plots visual cues (e.g., trend lines connecting the divergent points) and may trigger alerts. The “Wait 1 Bar” feature delays the signal to confirm alignment in trend direction between price and the indicator.
From similar divergence tools, we see that the algorithm typically involves:
- Locating a recent price high/low (e.g., High1 within swing length).
- Comparing the indicator value at that point with a previous high/low (e.g., High2).
- If the price shows a new extreme but the indicator doesn’t, a divergence is flagged.
This process automates what would otherwise require manual charting, saving time and improving accuracy.
How to Use the Divergence Detector Indicator
Setup in NinjaTrader 8:
- Installation: After purchasing and downloading the indicator from a reliable source like PatternSmart, import it into NinjaTrader 8 via the Tools > Import > NinjaScript Add-On menu.
- Adding to a Chart: Open a chart, right-click, and select Indicators. Search for “Divergence Detector” and add it.
- Input Configuration:
- Data Series Input: Select the plot from your chosen indicator (e.g., MACD’s difference line). Ensure the input has continuous values on every bar.
- Swing Length: Start with 12 for mid-term detection; adjust based on your timeframe (e.g., lower for intraday charts).
- Divergence Types: Enable regular, hidden, or both.
- Wait 1 Bar: Turn on for confirmed signals.
- Alerts: Configure sound, email, or pop-up notifications.
Here is how it works, after adding the Divergence detector, we need to add the indicator’s plot that we want to check divergence from the Data Series as image below. 
For example, if we want to use MACD to check divergence, then we need to find MACD from the Input series as image below, and choose the Plot MACD. We can also use the Diff plot of the MACD.

It will plot as chart below, please note that it will only plot the selected Plot of the indicator, since we choose MACD, it will only show the line of MACD, but not the AVG and Diff on sub chart.
- Scanning with Market Analyzer: Add the indicator to a Market Analyzer window to scan multiple symbols for divergence signals in real-time. Use the bullish/bearish signal plots for custom columns.
Practical Usage Tips:
- Combine with Other Tools: Use alongside support/resistance levels or trendlines for confluence. For example, a bullish divergence near a support zone strengthens the reversal signal.
- Timeframes: Effective on all timeframes, but test on historical data to optimize swing length.
- Risk Management: Divergences are not foolproof—always use stop-losses and position sizing. Avoid overtrading on unconfirmed signals.
- Customization: Experiment with different input indicators like RSI (for overbought/oversold conditions) or CCI (for momentum shifts).
For instance, on a daily chart of a stock, apply the detector to the MACD histogram. If it spots a bullish regular divergence during a downtrend, consider a long position once price confirms with a breakout.
Why the Divergence Detector is Useful for Technical Analysis
Divergence detection is a cornerstone of momentum-based trading strategies because it highlights shifts in market sentiment before they fully manifest in price. Here’s why this indicator is particularly valuable:
- Early Reversal Signals: By catching discrepancies between price and momentum, it provides advance warnings of trend exhaustion. Studies and backtests often show divergences preceding major reversals by several bars.
- Versatility Across Indicators: Its ability to work with any plottable indicator sets it apart, allowing customization for unique strategies (e.g., using it with ADX for trend strength divergences).
- Reduced Subjectivity: Automation eliminates bias in spotting swings, ensuring consistent application across assets.
- Efficiency in Scanning: Integrated with NinjaTrader’s tools, it enables quick screening of markets, ideal for active traders monitoring forex, stocks, or futures.
- Improved Win Rates: When combined with confirmation (e.g., “Wait 1 Bar”), it filters noise, potentially increasing the reliability of trades. Hidden divergences are especially useful for trend-following strategies.
- Educational Value: Visualizing divergences helps beginners understand momentum concepts, fostering better analytical skills.
In volatile markets like those in 2026, where economic uncertainties persist, tools like this help traders navigate reversals in assets influenced by global events.
Examples of Divergence in Action
- Bullish Regular Divergence: Price hits lower lows in a downtrend, but the RSI shows higher lows. The detector draws a line connecting these points, signaling a potential upturn.
- Bearish Hidden Divergence: In an uptrend, price makes higher highs, but the MACD shows lower highs. This suggests the rally may continue after a pullback.
Backtesting on historical data (e.g., via NinjaTrader’s Strategy Analyzer) can reveal how often these signals lead to profitable outcomes.
Conclusion
The Divergence Detector Indicator is a robust addition to any technical analyst’s toolkit, offering flexible, automated detection of key market signals on NinjaTrader 8. By understanding how to set it up and interpret its outputs, traders can gain an edge in identifying reversals and continuations. While no indicator guarantees success, its utility in highlighting momentum shifts makes it indispensable for informed decision-making. Always combine it with comprehensive risk management and ongoing market analysis for the best results.
Get this indicator now:Divergence detector from any input indicator’s plot on NinjaTrader 8.
