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.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.