OPEN-SOURCE SCRIPT
Profitable Pair Correlation Divergence Scanner v6

This strategy identifies divergence opportunities between two correlated assets using a combination of Z-Score spread analysis, trend confirmation, RSI & MACD momentum checks, correlation filters, and ATR-based stop-loss/take-profit management. It’s optimized for positive P&L and realistic trade execution.
Key Features:
Pair Divergence Detection:
Measures deviation between returns of two assets and identifies overbought/oversold spread conditions using Z-Score.
Trend Alignment:
Trades only in the direction of the primary asset’s trend using a fast EMA vs slow EMA filter.
Momentum Confirmation:
Confirms trades with RSI and MACD to reduce false signals.
Correlation Filter:
Ensures the pair is strongly correlated before taking trades, avoiding noisy signals.
Risk Management:
Dynamic ATR-based stop-loss and take-profit ensures proper reward-to-risk ratio.
Exit Conditions:
Automatically closes positions when Z-Score normalizes, or ATR-based exits are hit.
How It Works:
Calculate Returns:
Computes returns for both assets over the selected timeframe.
Z-Score Spread:
Calculates the spread between returns and normalizes it using moving average and standard deviation.
Trend Filter:
Only takes long trades if the fast EMA is above the slow EMA, and short trades if the fast EMA is below the slow EMA.
Momentum Confirmation:
Confirms trade direction with RSI (>50 for longs, <50 for shorts) and MACD alignment.
Correlation Check:
Ensures the pair’s recent correlation is strong enough to validate divergence signals.
Trade Execution:
Opens positions when Z-Score crosses thresholds and all conditions align. Positions close when Z-Score normalizes or ATR-based SL/TP is hit.
Plot Explanation:
Usage Tips:
Conclusion:
The Profitable Pair Correlation Divergence Scanner v6 is designed for traders who want systematic, low-risk, positive P&L trading opportunities with minimal manual monitoring. By combining trend alignment, momentum confirmation, correlation filters, and dynamic exits, it reduces false signals and improves execution reliability.
Run it on TradingView and watch how it captures divergence opportunities while maintaining positive P&L across trades.
Key Features:
Pair Divergence Detection:
Measures deviation between returns of two assets and identifies overbought/oversold spread conditions using Z-Score.
Trend Alignment:
Trades only in the direction of the primary asset’s trend using a fast EMA vs slow EMA filter.
Momentum Confirmation:
Confirms trades with RSI and MACD to reduce false signals.
Correlation Filter:
Ensures the pair is strongly correlated before taking trades, avoiding noisy signals.
Risk Management:
Dynamic ATR-based stop-loss and take-profit ensures proper reward-to-risk ratio.
Exit Conditions:
Automatically closes positions when Z-Score normalizes, or ATR-based exits are hit.
How It Works:
Calculate Returns:
Computes returns for both assets over the selected timeframe.
Z-Score Spread:
Calculates the spread between returns and normalizes it using moving average and standard deviation.
Trend Filter:
Only takes long trades if the fast EMA is above the slow EMA, and short trades if the fast EMA is below the slow EMA.
Momentum Confirmation:
Confirms trade direction with RSI (>50 for longs, <50 for shorts) and MACD alignment.
Correlation Check:
Ensures the pair’s recent correlation is strong enough to validate divergence signals.
Trade Execution:
Opens positions when Z-Score crosses thresholds and all conditions align. Positions close when Z-Score normalizes or ATR-based SL/TP is hit.
Plot Explanation:
- Z-Score: Blue line shows divergence magnitude.
- Entry Levels: Red/Green lines mark long/short thresholds.
- Exit Zone: Gray lines show normalization zone.
- EMA Trend Lines: Purple (fast), Orange (slow) for trend alignment.
- Correlation: Teal overlay shows current correlation strength.
Usage Tips:
- Use highly correlated pairs for best results (e.g., EURUSD/GBPUSD).
- Run on higher timeframe charts (1h or 4h) to reduce noise.
- Adjust ATR multiplier based on volatility to avoid premature stops.
- Combine with alerts for automated notifications or webhook execution.
Conclusion:
The Profitable Pair Correlation Divergence Scanner v6 is designed for traders who want systematic, low-risk, positive P&L trading opportunities with minimal manual monitoring. By combining trend alignment, momentum confirmation, correlation filters, and dynamic exits, it reduces false signals and improves execution reliability.
Run it on TradingView and watch how it captures divergence opportunities while maintaining positive P&L across trades.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。