OPEN-SOURCE SCRIPT
Correlation Scanner

๐ 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.
๐ฏ 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.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
๐ Join our FREE open Telegram channel! Everyone welcome! ๐ฑโจ t.me/smart_day_trader
Disclaimer
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.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
๐ Join our FREE open Telegram channel! Everyone welcome! ๐ฑโจ t.me/smart_day_trader
Disclaimer
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.