Modified Version of Strength of Divergence Across Multiple Indicators by reees
Purpose:
This Pine Script indicator is designed to identify and evaluate the strength of bullish and bearish divergences across multiple technical indicators. Divergences occur when the price of an asset is moving in one direction while a technical indicator is moving in the opposite direction, potentially signaling a trend reversal.
Key Features:
1. Multiple Indicator Support: The script now analyzes divergences for the following indicators: * RSI (Relative Strength Index) * OBV (On-Balance Volume) * MACD (Moving Average Convergence/Divergence) * STOCH (Stochastic Oscillator) * CCI (Commodity Channel Index) * MFI (Money Flow Index) * AO (Awesome Oscillator) * CMF (Chaikin Money Flow) - Newly added * VWMACD (Volume-Weighted MACD) - Newly added
2. Customizable Divergence Parameters: * Bullish/Bearish: Enable or disable the detection of bullish and bearish divergences independently. * Regular/Hidden: Detect both regular and hidden divergences (hidden divergences can indicate trend continuation). * Broken Trendline Exclusion: Optionally ignore divergences where the trendline connecting price pivots is broken by an intermediate pivot. * Pivot Lookback Periods: Adjust the number of bars used to identify valid pivot highs and lows for divergence calculations. * Weighting: Assign different weights to regular vs. hidden divergences and to the relative change in price vs. the indicator.
3. Indicator-Specific Settings: * Weight: Each indicator can be assigned a weight, influencing its contribution to the overall divergence strength calculation. * Extreme Value: Define a threshold above which an indicator's divergence is considered "extreme," giving it a higher strength rating.
4. Divergence Strength Calculation: * For each indicator, the script calculates a divergence "degree" based on the magnitude of the divergence and the user-defined weightings. * The total divergence strength is the sum of the individual indicator divergence degrees. * Strength is categorized as "Extreme," "Very strong," "Strong," "Moderate," "Weak," or "Very weak."
5. Visualization: * Divergence Lines: The script draws lines on the chart connecting the price and indicator pivots that form a divergence (optional, with customizable transparency). * Labels: Labels display the total divergence strength and a breakdown of each indicator's contribution. The size and visibility of labels are based on the strength.
6. Alerts: * The script can generate alerts when the total divergence strength exceeds a user-defined threshold.
New Indicators (CMF and VWMACD):
* Chaikin Money Flow (CMF): * Purpose: Measures the buying and selling pressure by analyzing the relationship between price, volume, and the accumulation/distribution line. * Divergence: A bullish CMF divergence occurs when the price makes a lower low, but the CMF makes a higher low (suggesting increasing buying pressure). A bearish divergence is the opposite. * Volume-Weighted MACD (VWMACD): * Purpose: Similar to the standard MACD but uses volume-weighted moving averages instead of simple moving averages, giving more weight to periods with higher volume. * Divergence: Divergences are interpreted similarly to the standard MACD, but the VWMACD can be more sensitive to volume changes.
How It Works (Simplified):
1. Pivot Detection: The script identifies pivot highs and lows in both price and the selected indicators using the specified lookback periods. 2. Divergence Check: For each indicator: * It checks if a series of pivots in price and the indicator are diverging (e.g., price makes a lower low, but the indicator makes a higher low for a bullish divergence). * It calculates the divergence degree based on the difference in price and indicator values, weightings, and whether it's a regular or hidden divergence. 3. Strength Aggregation: The script sums up the divergence degrees of all enabled indicators to get the total divergence strength. 4. Visualization and Alerts: It draws lines and labels on the chart to visualize the divergences and generates alerts if the total strength exceeds the set threshold.
Benefits:
* Comprehensive Divergence Analysis: By considering multiple indicators, the script provides a more robust assessment of potential trend reversals. * Customization: The many adjustable parameters allow traders to fine-tune the script to their specific trading style and preferences. * Objective Strength Evaluation: The divergence strength calculation and categorization offer a more objective way to evaluate the significance of divergences. * Early Warning System: Divergences can often precede significant price movements, making this script a valuable tool for anticipating potential trend changes. * Volume Confirmation: The inclusion of CMF and VWMACD add volume-based confirmation to the divergence signals, potentially increasing their reliability.
Limitations:
* Lagging Indicators: Most of the indicators used are lagging, meaning they are based on past price data. Divergences may sometimes occur after a significant price move has already begun. * False Signals: No indicator is perfect, and divergences can sometimes produce false signals, especially in choppy or ranging markets. * Subjectivity: While the script aims for objectivity, some settings (like weightings and extreme values) still involve a degree of subjective judgment.
In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.