RrBc2

Investing - Correlation Table

This correlation tables idea is nothing new, many sites provides it.
However, I couldn't find any simple correlation indicator on TradingView despite how simple this indicator is.

This indicator works as its called. Calculating the correlation between 2 projects (can be used in stocks as well) using the 'ta.correlation' feature built into pinescript.

When it comes to investing, we do not want our stocks / crypto project to be heavily correlated to each other.
If they are heavily correlated to each other, then there isn't much point in diversifying.
That being said, it can be useful for traders who trade multiple pairs.

-----------------------------------------------------------------------------------------------------------------------------------------------------------
In this indicator, consist of 5 primary input and 15 secondary input (Symbol List).

Correlation Source:
This input options allow you to change how the correlation is calculated. By default, it uses 'close'.

Correlation Percentage(%):
This input options allows you configure how many (%) of correlation is considered as 'decoupled'.
This correlation will only move between -100% ~ 100%.

100% refers to it moving together.
-100% refers to it moving the opposite direction.

For example, Project A rises in Price, what is the possibility of Project B following:
  • A 100% correlation between Project A and Project B, refers to Project B will follow Project A movement.
  • A 50% correlation between Project A and Project B, refers to there is only 50% chance for Project B to follow Project A movement.
  • A -20% correlation between Project A and Project B, refers to there is a 20% chance of Project B moving the opposite direction of Project A
(Refers to the table on chart above to better understand what the numbers means. DOT/USD has a 100% correlation to DOT/USD. However. MXCUSDT has a -37.2% correlation to DOT/USD.)

Amounts Bars To Check:
This input options will check the amount of bars since the last bar in the chart.
If you want to know the correlation of the past 100 days in a daily chart, you will enter '100' into this options and it will check only the past 100 days.

Symbol List
This will allow you to input all the project symbol ticker ID to add into the correlation table.

-----------------------------------------------------------------------------------------------------------------------------------------------------------
Originally, I wish to use for loop to go through the symbol list to reduce the amount of code required. However, due to limitation of 'request.security' feature, I had to abandon that idea and use hard-coded for requesting security and use a while loop to identify the symbol correlation value in the array set then set the table value accordingly.

If there is any script writer could improve this or any unclear explanation, feel free to drop a comment below.
Mã nguồn mở

Với tinh thần TradingView, tác giả của tập lệnh này đã xuất bản nó dưới dạng mã nguồn mở, vì vậy các nhà giao dịch có thể hiểu và xác minh nó. Chúc mừng tác giả! Bạn có thể sử dụng mã này miễn phí, nhưng việc sử dụng lại mã này trong một ấn phẩm chịu sự điều chỉnh của Nội quy nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?