OPEN-SOURCE SCRIPT
Intermarket Correlation Oscillator (ICO)

The Intermarket Correlation Oscillator (ICO) is a TradingView indicator that helps traders analyze the relationship between two assets, such as stocks, indices, or cryptocurrencies, by measuring their price correlation. It displays this correlation as an oscillator ranging from -1 to +1, making it easy to spot whether the assets move together, oppositely, or independently. A value near +1 indicates strong positive correlation (assets move in the same direction), near -1 shows strong negative correlation (opposite movements), and near 0 suggests no correlation. This tool is ideal for confirming trends, spotting divergences, or identifying hedging opportunities across markets.
How It Works?
The ICO calculates the Pearson correlation coefficient between the chart’s primary asset (e.g., Apple stock) and a secondary asset you choose (e.g., SPY for the S&P 500) over a specified number of bars (default: 20). The oscillator is plotted in a separate pane below the chart, with key levels at +0.8 (overbought, strong positive correlation) and -0.8 (oversold, strong negative correlation). A midline at 0 helps gauge neutral correlation. When the oscillator crosses these levels or the midline, labels ("OB" for overbought, "OS" for oversold) and alerts notify you of significant shifts. Shaded zones highlight extreme correlations (red for overbought, green for oversold) if enabled.
Why Use the ICO?
Trend Confirmation: High positive correlation (e.g., SPY and QQQ both rising) confirms market trends.
Divergence Detection: Negative correlation (e.g., DXY rising while stocks fall) signals potential reversals.
Hedging: Identify negatively correlated assets to balance your portfolio.
Market Insights: Understand how assets like stocks, bonds, or crypto interact.
Easy Steps to Use the ICO in TradingView
Add the Indicator:
Open TradingView and load your chart (e.g., AAPL on a daily timeframe).
Go to the Pine Editor at the bottom of the TradingView window.
Copy and paste the ICO script provided earlier.
Click "Add to Chart" to display the oscillator below your price chart.
Configure Settings:
Click the gear icon next to the indicator’s name in the chart pane to open settings.
Secondary Symbol: Choose an asset to compare with your chart’s symbol (e.g., "SPY" for S&P 500, "DXY" for USD Index, or "BTCUSD" for Bitcoin). Default is SPY.
Correlation Lookback Period: Set the number of bars for calculation (default: 20). Use 10-14 for short-term trading or 50 for longer-term analysis.
Overbought/Oversold Levels: Adjust thresholds (default: +0.8 for overbought, -0.8 for oversold) to suit your strategy. Lower values (e.g., ±0.7) give more signals.
Show Midline/Zones: Check boxes to display the zero line and shaded overbought/oversold zones for visual clarity.
Interpret the Oscillator:
Above +0.8: Strong positive correlation (red zone). Assets move together.
Below -0.8: Strong negative correlation (green zone). Assets move oppositely.
Near 0: No clear relationship (midline reference).
Labels: "OB" or "OS" appears when crossing overbought/oversold levels, signaling potential correlation shifts.
Set Up Alerts:
Right-click the indicator, select "Add Alert."
Choose conditions like "Overbought Alert" (crossing above +0.8), "Oversold Alert" (crossing below -0.8), or zero-line crossings for bullish/bearish correlation shifts.
Configure notifications (e.g., email, SMS) to stay informed.
Apply to Trading:
Use positive correlation to confirm trades (e.g., buy AAPL if SPY is rising and correlation is high).
Spot divergences for reversals (e.g., stocks dropping while DXY rises with negative correlation).
Combine with other indicators like RSI or moving averages for stronger signals.
Tips for New Users
Start with related assets (e.g., SPY and QQQ for tech stocks) to see clear correlations.
Test on a demo account to understand signals before trading live.
Be aware that correlation is a lagging indicator; confirm signals with price action.
If the secondary symbol doesn’t load, ensure it’s valid on TradingView (e.g., use correct ticker format).
The ICO is a powerful, beginner-friendly tool to explore intermarket relationships, enhancing your trading decisions with clear visual cues and alerts.
How It Works?
The ICO calculates the Pearson correlation coefficient between the chart’s primary asset (e.g., Apple stock) and a secondary asset you choose (e.g., SPY for the S&P 500) over a specified number of bars (default: 20). The oscillator is plotted in a separate pane below the chart, with key levels at +0.8 (overbought, strong positive correlation) and -0.8 (oversold, strong negative correlation). A midline at 0 helps gauge neutral correlation. When the oscillator crosses these levels or the midline, labels ("OB" for overbought, "OS" for oversold) and alerts notify you of significant shifts. Shaded zones highlight extreme correlations (red for overbought, green for oversold) if enabled.
Why Use the ICO?
Trend Confirmation: High positive correlation (e.g., SPY and QQQ both rising) confirms market trends.
Divergence Detection: Negative correlation (e.g., DXY rising while stocks fall) signals potential reversals.
Hedging: Identify negatively correlated assets to balance your portfolio.
Market Insights: Understand how assets like stocks, bonds, or crypto interact.
Easy Steps to Use the ICO in TradingView
Add the Indicator:
Open TradingView and load your chart (e.g., AAPL on a daily timeframe).
Go to the Pine Editor at the bottom of the TradingView window.
Copy and paste the ICO script provided earlier.
Click "Add to Chart" to display the oscillator below your price chart.
Configure Settings:
Click the gear icon next to the indicator’s name in the chart pane to open settings.
Secondary Symbol: Choose an asset to compare with your chart’s symbol (e.g., "SPY" for S&P 500, "DXY" for USD Index, or "BTCUSD" for Bitcoin). Default is SPY.
Correlation Lookback Period: Set the number of bars for calculation (default: 20). Use 10-14 for short-term trading or 50 for longer-term analysis.
Overbought/Oversold Levels: Adjust thresholds (default: +0.8 for overbought, -0.8 for oversold) to suit your strategy. Lower values (e.g., ±0.7) give more signals.
Show Midline/Zones: Check boxes to display the zero line and shaded overbought/oversold zones for visual clarity.
Interpret the Oscillator:
Above +0.8: Strong positive correlation (red zone). Assets move together.
Below -0.8: Strong negative correlation (green zone). Assets move oppositely.
Near 0: No clear relationship (midline reference).
Labels: "OB" or "OS" appears when crossing overbought/oversold levels, signaling potential correlation shifts.
Set Up Alerts:
Right-click the indicator, select "Add Alert."
Choose conditions like "Overbought Alert" (crossing above +0.8), "Oversold Alert" (crossing below -0.8), or zero-line crossings for bullish/bearish correlation shifts.
Configure notifications (e.g., email, SMS) to stay informed.
Apply to Trading:
Use positive correlation to confirm trades (e.g., buy AAPL if SPY is rising and correlation is high).
Spot divergences for reversals (e.g., stocks dropping while DXY rises with negative correlation).
Combine with other indicators like RSI or moving averages for stronger signals.
Tips for New Users
Start with related assets (e.g., SPY and QQQ for tech stocks) to see clear correlations.
Test on a demo account to understand signals before trading live.
Be aware that correlation is a lagging indicator; confirm signals with price action.
If the secondary symbol doesn’t load, ensure it’s valid on TradingView (e.g., use correct ticker format).
The ICO is a powerful, beginner-friendly tool to explore intermarket relationships, enhancing your trading decisions with clear visual cues and alerts.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının oluşturucusu bunu açık kaynaklı hale getirmiştir, böylece yatırımcılar betiğin işlevselliğini inceleyip doğrulayabilir. Yazara saygı! Ücretsiz olarak kullanabilirsiniz, ancak kodu yeniden yayınlamanın Site Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının oluşturucusu bunu açık kaynaklı hale getirmiştir, böylece yatırımcılar betiğin işlevselliğini inceleyip doğrulayabilir. Yazara saygı! Ücretsiz olarak kullanabilirsiniz, ancak kodu yeniden yayınlamanın Site Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.