OPEN-SOURCE SCRIPT
Sector Correlation Matrix [LuxAlgo]

The Sector Correlation Matrix indicator provides a quantitative measure of the statistical relationship between a selected asset and a benchmark to help traders identify market synchronization and relative strength.
🔶 USAGE
This tool is particularly useful for relative strength analysis. For example, if a stock is "Decoupled" while the benchmark is crashing, it may indicate idiosyncratic strength. Conversely, traders can use "Strong Positive" states to confirm that a price move is part of a broader market trend rather than an isolated event.
The indicator categorizes market relationships into five distinct states based on the coefficient value:
🔶 DETAILS
The script utilizes the Pearson Correlation Coefficient to calculate the rolling correlation between the current chart's closing price and a user-defined benchmark (such as SPY, QQQ, or BTC). This statistical method measures the linear correlation between two sets of data, resulting in a value between -1 (perfect inverse correlation) and 1 (perfect positive correlation).
The visual output includes a dedicated pane with a correlation oscillator and an on-screen dashboard that provides real-time metrics, allowing for a quick assessment of the current market state without manually comparing multiple charts.
Pine Script®
🔶 SETTINGS
🔹 Logic Settings
🔹 Dashboard
🔶 USAGE
This tool is particularly useful for relative strength analysis. For example, if a stock is "Decoupled" while the benchmark is crashing, it may indicate idiosyncratic strength. Conversely, traders can use "Strong Positive" states to confirm that a price move is part of a broader market trend rather than an isolated event.
The indicator categorizes market relationships into five distinct states based on the coefficient value:
- Strong Positive (> 0.7): High degree of synchronization; the assets move together closely.
- Moderate Positive (> 0.3): General tendency to move in the same direction.
- Decoupled / Neutral (-0.3 to 0.3): No significant linear relationship; the asset is moving independently.
- Moderate Negative (< -0.3): General tendency to move in opposite directions.
- Strong Negative (< -0.7): High degree of inverse synchronization.
🔶 DETAILS
The script utilizes the Pearson Correlation Coefficient to calculate the rolling correlation between the current chart's closing price and a user-defined benchmark (such as SPY, QQQ, or BTC). This statistical method measures the linear correlation between two sets of data, resulting in a value between -1 (perfect inverse correlation) and 1 (perfect positive correlation).
The visual output includes a dedicated pane with a correlation oscillator and an on-screen dashboard that provides real-time metrics, allowing for a quick assessment of the current market state without manually comparing multiple charts.
🔶 SETTINGS
🔹 Logic Settings
- Benchmark Asset: The ticker symbol to compare the current asset against (e.g., SPY, QQQ, BTCUSDT).
- Correlation Length: The lookback period used to calculate the Pearson Correlation Coefficient.
🔹 Dashboard
- Show Dashboard: Enable or disable the on-screen information table.
- Position: Select the dashboard location (Top Right, Bottom Right, or Bottom Left).
- Size: Adjust the size of the dashboard text and cells (Tiny to Huge).
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
All content & scripts provided by LuxAlgo are for educational purposes only and are not financial advice.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
All content & scripts provided by LuxAlgo are for educational purposes only and are not financial advice.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.