All Divergences with trend / SL
Jul 9, 2024

The All Divergences with trend / SL indicator is a comprehensive strategy tool that identifies regular and hidden divergences across multiple technical oscillators to signal potential market reversals. By combining cross-indicator analysis with a robust trend filter and automated risk management, it aims to provide high-probability entry points aligned with the prevailing market direction.
Usage
The Usage section focuses on identifying market turning points by scanning for discrepancies between price action and momentum. Users can select from a wide array of indicators, including MACD, RSI, Stochastics, and more. When a divergence is detected, the script plots visual cues such as pivot points and divergence lines directly on the chart.
To enhance signal reliability, the script includes:
- Trend Filtering: An integrated Moving Average (MA) filter ensures that long signals only occur in uptrends and short signals in downtrends.
- Automated Exits: The strategy uses percentage-based Stop-Loss (SL) and Take-Profit (TP) levels.
- MA Risk Management: An optional setting allows the script to close positions if a specific number of candles close against the trend, providing an additional layer of protection during high volatility.
Details
Divergence occurs when the price makes a new high (or low) that is not confirmed by the underlying oscillator. This script automates the detection of two main types:
- Regular Divergence: Typically signals a trend reversal.
- Hidden Divergence: Typically signals trend continuation.
The strategy implementation utilizes a pivot-based detection algorithm (defaulting to a 9-period pivot) to identify significant peaks and troughs. By checking multiple indicators simultaneously, the tool identifies "confluence" where several oscillators confirm the same reversal signal, potentially increasing the setup's accuracy.
Settings
Strategy Controls
- Enable Long/Short Strategy: Toggles the ability for the script to enter long or short positions.
- Long/Short SL %: Sets the stop-loss distance from the entry price as a percentage.
- Long/Short TP %: Sets the take-profit target as a percentage.
MA Trend
- Enable MA Trend: Activates the trend filter to restrict trades to the direction of the moving average.
- MA Type: Selects the calculation method (SMA, EMA, HMA, etc.).
- MA Length: Determines the lookback period for the trend filter.
Additional Risk Management
- Use MA Risk Management: Enables an experimental exit logic based on price action relative to the MA.
- MA Risk Exit Candles: Sets the number of consecutive closes against the trend required to trigger an early exit.
Divergence Indicators
- Indicator Toggles: Individual checkboxes for MACD, RSI, Stochastic, CCI, Momentum, OBV, VWMA, CMF, MFI, and several advanced oscillators like SMI Ergodic and Logistic Dominance.
- Indicator Parameters: Specific inputs for each selected oscillator (e.g., Fast/Slow lengths for MACD).
FAQ
How do I interpret the divergence lines?
Regular divergence lines often suggest the current trend is losing momentum and may reverse, while hidden divergence lines suggest the trend is likely to continue after a brief pullback.
Which indicator is best for divergences?
While RSI and MACD are popular choices, using multiple indicators (confluence) often provides more reliable signals than relying on a single oscillator.
How can I access All Divergences with trend / SL?
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.