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:

نص برمجي مفتوح المصدر

قام مؤلف هذا النص البرمجي بنشره وجعله مفتوح المصدر، بحيث يمكن للمتداولين فهمه والتحقق منه، وهو الأمر الذي يدخل ضمن قيم TradingView. تحياتنا للمؤلف! يمكنك استخدامه مجانًا، ولكن إعادة استخدام هذا الكود في منشور تحكمه قواعد الموقع. يمكنك جعله مفضلاً لاستخدامه على الرسم البياني.

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.

هل تريد استخدام هذا النص البرمجي على الرسم البياني؟

التحليلات ذات الصلة