OPEN-SOURCE SCRIPT

Correlation Scanner

121
📊 CORRELATION SCANNER - Financial Instruments Correlation Analyzer

🎯 ORIGINALITY AND PURPOSE

Correlation Scanner is a professional tool for analyzing correlation relationships between different financial instruments. Unlike standard correlation indicators that show the relationship between only two instruments, this script allows you to simultaneously track the correlation of up to 10 customizable instruments with a selected base asset.

The indicator is designed for traders working with cross-market analysis, portfolio diversification, and searching for related assets for arbitrage strategies.

🔧 HOW IT WORKS

The indicator uses the built-in ta.correlation() function to calculate the Pearson correlation coefficient between instrument closing prices over a specified period. Mathematical foundation:

1. Correlation Calculation: for each instrument, the correlation coefficient with the base asset is calculated over N bars (default 60)

2. Results Sorting: instruments are automatically ranked by absolute correlation value (from strongest to weakest)

3. Visualization: results are displayed in a table with color coding:
- Green: positive correlation (instruments move in the same direction)
- Red: negative correlation (instruments move in opposite directions)
- Color intensity depends on correlation strength

4. Correlation Strength Classification:
- Very Strong (💪💪💪): |r| > 0.8 — very strong relationship
- Strong (💪💪): |r| > 0.6 — strong relationship
- Medium (💪): |r| > 0.4 — medium relationship
- Weak: |r| > 0.2 — weak relationship
- Very Weak: |r| ≤ 0.2 — very weak relationship

📋 SETTINGS AND USAGE

MAIN PARAMETERS:
• Main Instrument — base instrument for comparison (default TVC:DXY - US Dollar Index)
• Correlation Period — calculation period in bars (10-500, default 60)
• Number of Instruments to Display — number of instruments to show (1-10)
• Table Position — table location on the chart

INSTRUMENT CONFIGURATION:
The indicator allows configuring up to 10 instruments for analysis. For each, you can specify:
• Instrument — instrument ticker (e.g., FX_IDC:EURUSD)
• Name — display name (emojis supported)

VISUAL SETTINGS:
• Show Chart Label with Correlation — display current chart's correlation with base instrument
• Table Header Color — table header color
• Table Row Background — table row background color

💡 USAGE EXAMPLES

1. DOLLAR IMPACT ANALYSIS: set DXY as the base instrument and track how dollar index changes affect currency pairs, gold, and cryptocurrencies

2. HEDGING ASSETS SEARCH: find instruments with strong negative correlation for risk diversification

3. PAIRS TRADING: identify assets with high positive correlation to find divergences and arbitrage opportunities

4. CROSS-MARKET ANALYSIS: track relationships between stocks, bonds, commodities, and currencies

5. SYSTEMIC RISK ASSESSMENT: identify periods of increased correlation between assets, which may indicate systemic risks

⚠️ IMPORTANT NOTES

• Correlation does NOT imply causation
• Correlation can change over time — regularly review the analysis period
• High past correlation doesn't guarantee the relationship will persist in the future
• Recommended to use the indicator in combination with fundamental analysis

🔔 ALERTS

The indicator includes a built-in alert condition: triggers when strong correlation (|r| > 0.8) is detected between the current chart and the base instrument.

Penafian

Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.