LeviathanCapital

Correlation Matrix + Heatmap - By Leviathan

A quick and easy way to visualize the correlation between 10 different symbols over a custom period of time, in the form of a matrix with a heatmap visualization and additional tools such as price increase/decrease %, multi-timeframe function, customizable appearance and more.

The indicator displays correlation coefficients for each pair of 10 assets in a matrix format, where the rows and columns represent the assets being compared between each other. The color of each cell corresponds with the strength of the correlation coefficient, allowing you to quickly identify which assets are strongly correlated, and which are not, and use that information to adjust risk or even get trade ideas. Coupled with the "Price Change" function, the script will help you find trade opportunities based on eg. the long-term correlation strength and short-term price direction differences between two assets. The "Correlation Length" input defines the number of bars used for calculating the correlation, while "Price Change Length" defines the bar to which the current price is compared when calculating price change (eg. the input 20 means that the script will compare the price of the candle close that occurred 20 bars ago and the current price).

Correlation coefficient:
The correlation coefficient is a statistical measure that quantifies the degree of linear relationship between two variables. The correlation coefficient ranges from -1 to 1, with 1 being perfect positive correlation and -1 being perfect negative correlation.

• A correlation coefficient of 1 indicates a perfect positive linear relationship between two variables. This means that when one variable increases, the other variable also increases in a proportional manner.
• A correlation coefficient of 0 indicates no linear relationship between two variables. This means that changes in one variable do not affect the other variable.
• A correlation coefficient of -1 indicates a perfect negative linear relationship between two variables. This means that when one variable increases, the other variable decreases in a proportional manner.

Inspired by @RicardoSantos's script

Register to support free indicators:
BYBIT: partner.bybit.com/b/Leviathan
WOO X: referral.woo.org/7MY2
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

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.

Want to use this script on a chart?