YoavShachak

Symbols Correlation, built for pair trading

Overview:
This script is designed for pairs trading. If you are not familiar with pairs trading, I suggest learning about it, as it can be a profitable strategy in neutral markets (or neutral trends between two assets). The correlation between two assets is the foundation of pairs trading, and without it, the chances of making a profit are low.
Correlation can be described in two opposite ways:
  • 1: Absolute positive correlation (meaning the asset prices move together).
  • -1: Absolute negative correlation (meaning the asset prices move in opposite directions).
Any value between 1 and -1 indicates some degree of correlation, but generally, values higher than 0.7 or lower than -0.7 are considered significant.

Features:
Typically, correlation is measured using the closing prices. This script adds three more correlation studies based on open, high, and low prices. By using all four lines, we can get a better understanding of the pair's correlation.

How to Read This Indicator:
To use this indicator effectively, you need to input your pair as a ratio. For example, if your pair is TSN and ZBH, enter it in the symbol search as: TSN/ZBH
  • Gray Area: This area indicates "no high correlation" (default is between -0.8 and 0.8, adjustable in the settings).
  • Gray Line: This represents the close correlation within the "no high correlation" range.
  • Green Line: This represents the close correlation within the "high correlation" range.
  • Dot Lines: These represent the open, high, and low correlations.

Example Interpretations:
  • A: All four lines are close together & the line is green – very good correlation!
  • B: The line is gray, and the dot lines are apart – not a strong correlation.
  • C: When the close correlation remains green for a long time, it signals a strong correlation.

Application in Pairs Trading:
In pairs trading, aim for the highest possible correlation, and it is important to have a sustained correlation over a long period. Pairs that correlate only part of the year but not consistently are less reliable for pairs trading.

This is an example for good correlation for pairs trading:

This is an example for bad correlation for pairs trading:

Here is a view of my full indicators when doing pairs trading:

Skrip sumber terbuka

Dalam semangat TradingView yang sebenar, penulis skrip ini telah menerbitkannya dengan menggunakan sumber terbuka supaya pedagang-pedagang dapat memahami dan mengesahkannya. Sorakan kepada penulis! Anda dapat menggunakannya secara percuma tetapi penggunaan semula kod ini dalam penerbitan adalah dikawalselia oleh Peraturan Dalaman. Anda boleh menyukainya untuk menggunakannya pada carta.

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.

Ingin menggunakan skrip ini pada carta?