OPEN-SOURCE SCRIPT
Updated

[JHF] Correlation Coefficient Aggregator

279
Overview
The Correlation Coefficient Aggregator (CCA) indicator is designed to help traders analyze the correlation between the price of a selected asset and another asset's price over multiple timeframes. By calculating the correlation coefficients for multiple periods and displaying them in an easy-to-read format, the CCA indicator provides valuable insights into the strength and direction of the relationship between the two assets.

How It Works
The CCA indicator calculates the correlation coefficients for four different timeframes: 15, 30, 90, and 120 days. The indicator then displays the correlation coefficients in color-coded labels, with bright red for -1 (perfect negative correlation), bright green for 1 (perfect positive correlation), and shades in between for various degrees of correlation. Additionally, the CCA indicator calculates and displays the average correlation coefficient of the four timeframes, shown in gold.

Customization Options:

  • Precision: The number of decimal places displayed for the correlation coefficients can be customized.
  • Logging: Option to log the correlation values in the Pine Script logs for further analysis.


How to Use
The CCA indicator can be used to identify potential diversification opportunities or risk exposure in a trading portfolio. By analyzing the correlation between two assets, traders can gain insights into how the assets may behave in relation to each other. A strong positive correlation indicates that the assets tend to move in the same direction, while a strong negative correlation suggests that they move in opposite directions. A correlation near zero indicates little or no relationship between the assets.

Benefits
  • Analyze correlation across multiple timeframes
  • Identify potential diversification opportunities or risk exposure
  • Visualize the strength and direction of the relationship between two assets
  • Gain insights into potential asset behavior
  • Customize the precision of displayed values
  • Optionally log correlation values for detailed analysis (spreadsheets)


How to Apply the Indicator
To apply the CCA indicator to your TradingView chart, follow these steps:

  • Input the desired symbol and source (e.g., closing price) in the script settings.
  • Adjust the lengths for the correlation calculations if needed.
  • Set the precision for the displayed values.
  • Enable or disable logging of correlation values.
  • The indicator will then display the correlation coefficients for the selected timeframes, as well as the average correlation coefficient.


-----------------

Disclaimer
The information contained in my Scripts/Indicators/Ideas/Algos/Systems does not constitute financial advice or a solicitation to buy or sell any securities of any type. I will not accept liability for any loss or damage, including without limitation any loss of profit, which may arise directly or indirectly from the use of or reliance on such information.

All investments involve risk, and the past performance of a security, industry, sector, market, financial product, trading strategy, backtest, or individual's trading does not guarantee future results or returns. Investors are fully responsible for any investment decisions they make. Such decisions should be based solely on an evaluation of their financial circumstances, investment objectives, risk tolerance, and liquidity needs.

My Scripts/Indicators/Ideas/Algos/Systems are only for educational purposes!
Release Notes
Fixed Labels to adapt based on selected timeframe.
Release Notes
Updated the default ticker to be INDEX:BTCUSD instead of Coinbase's BTCUSD.
Release Notes
Major revision
  • Added precision input
  • Added logs generation
  • Renamed script
  • Disabled the ticker confirmation box popping up by default.
  • Labels now always are closed to 0 on the Y-Axis so you can stop searching for them.
Release Notes
Updated codebase to shorten most variables.
Release Notes
Updated chart.
Release Notes
Improved logging data integrity with the values shown on the indicator by storing its value.

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.