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:

Script de código aberto

Dentro do verdadeiro espírito TradingView, o autor deste script publicou ele como um script de código aberto, para que os traders possam compreender e checar ele. Um viva ao autor! Você pode usá-lo gratuitamente, mas a reutilização deste código em uma publicação é regida pelas Regras da Casa. Você pode favoritá-lo para usá-lo em um gráfico.

Aviso legal

As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.

Quer usar esse script no gráfico?