OPEN-SOURCE SCRIPT
Trend Confluence Indicator

identify potential trend reversals by combining signals from three popular technical indicators: MACD, Stochastic Oscillator, and ADX.
Here's a breakdown of its components and how it defines confluence:
MACD (Moving Average Convergence Divergence):
Purpose: This indicator helps to spot changes in the strength, direction, momentum, and duration of a trend.
Signals:
A bullish MACD signal is generated when the MACD line crosses above its signal line, indicating increasing bullish momentum.
A bearish MACD signal is generated when the MACD line crosses below its signal line, indicating increasing bearish momentum.
Stochastic Oscillator:
Purpose: This momentum indicator compares a security's closing price to its price range over a given period, identifying overbought and oversold conditions. It also shows momentum shifts.
Signals:
A bullish Stochastic signal is typically a crossover of the %K line above the %D line.
A bearish Stochastic signal is a crossover of the %K line below the %D line.
ADX (Average Directional Index):
Purpose: The ADX measures the strength of a trend, not its direction. Higher ADX values indicate a stronger trend, while lower values suggest a weak or ranging market.
Role in Confluence: For reversal signals, the indicator looks for the ADX to be below a specified threshold (defaulting to 25). The idea is that reversals are more likely to occur when the existing trend is weak or the market is consolidating, rather than when a strong trend is in full force.
How Confluence is Currently Defined (Simplified for Debugging):
In its current state (with the debugging simplification active in the Canvas), a signal is generated when:
Bullish Reversal (Trend Up): The MACD line crosses above its signal line AND the Stochastic %K line crosses above its %D line.
Bearish Reversal (Trend Down): The MACD line crosses below its signal line AND the Stochastic %K line crosses below its %D line.
When these simplified conditions are met, the indicator plots "Reversal Up" (▲) or "Reversal Down" (▼) labels directly on your chart. It also plots the individual MACD, Stochastic, and ADX lines on separate sub-panes to help you visualize the underlying indicator movements.
Original (More Comprehensive) Confluence (Commented Out):
The Canvas also contains commented-out code for the original, more stringent confluence conditions. These would have added further filters:
For Bullish Reversal: The Stochastic %K and %D lines would also need to be below the stochOversold level (e.g., 20) when the crossover occurred, and the ADX would need to be below the adxThreshold.
For Bearish Reversal: The Stochastic %K and %D lines would also need to be above the stochOverbought level (e.g., 80) when the crossover occurred, and the ADX would need to be below the adxThreshold.
Once you confirm the indicator is showing signals with the simplified logic, you can uncomment these original lines in the Canvas to activate the more precise confluence criteria, or adjust the input parameters to fine-tune its sensitivity.
Here's a breakdown of its components and how it defines confluence:
MACD (Moving Average Convergence Divergence):
Purpose: This indicator helps to spot changes in the strength, direction, momentum, and duration of a trend.
Signals:
A bullish MACD signal is generated when the MACD line crosses above its signal line, indicating increasing bullish momentum.
A bearish MACD signal is generated when the MACD line crosses below its signal line, indicating increasing bearish momentum.
Stochastic Oscillator:
Purpose: This momentum indicator compares a security's closing price to its price range over a given period, identifying overbought and oversold conditions. It also shows momentum shifts.
Signals:
A bullish Stochastic signal is typically a crossover of the %K line above the %D line.
A bearish Stochastic signal is a crossover of the %K line below the %D line.
ADX (Average Directional Index):
Purpose: The ADX measures the strength of a trend, not its direction. Higher ADX values indicate a stronger trend, while lower values suggest a weak or ranging market.
Role in Confluence: For reversal signals, the indicator looks for the ADX to be below a specified threshold (defaulting to 25). The idea is that reversals are more likely to occur when the existing trend is weak or the market is consolidating, rather than when a strong trend is in full force.
How Confluence is Currently Defined (Simplified for Debugging):
In its current state (with the debugging simplification active in the Canvas), a signal is generated when:
Bullish Reversal (Trend Up): The MACD line crosses above its signal line AND the Stochastic %K line crosses above its %D line.
Bearish Reversal (Trend Down): The MACD line crosses below its signal line AND the Stochastic %K line crosses below its %D line.
When these simplified conditions are met, the indicator plots "Reversal Up" (▲) or "Reversal Down" (▼) labels directly on your chart. It also plots the individual MACD, Stochastic, and ADX lines on separate sub-panes to help you visualize the underlying indicator movements.
Original (More Comprehensive) Confluence (Commented Out):
The Canvas also contains commented-out code for the original, more stringent confluence conditions. These would have added further filters:
For Bullish Reversal: The Stochastic %K and %D lines would also need to be below the stochOversold level (e.g., 20) when the crossover occurred, and the ADX would need to be below the adxThreshold.
For Bearish Reversal: The Stochastic %K and %D lines would also need to be above the stochOverbought level (e.g., 80) when the crossover occurred, and the ADX would need to be below the adxThreshold.
Once you confirm the indicator is showing signals with the simplified logic, you can uncomment these original lines in the Canvas to activate the more precise confluence criteria, or adjust the input parameters to fine-tune its sensitivity.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.