OPEN-SOURCE SCRIPT

Pearson Correlation [Mr_Rakun]

932
Pearson Correlation

This script calculates the Pearson correlation coefficient (r) between the closing price of the current asset and another selected asset.

🔍 How It Works:
• The user selects a correlation period (default: 20) and a symbol (default: ETH/USDT).
• The script retrieves the closing prices of both assets.
• The Pearson correlation formula is applied:
r = \frac{n(\sum xy) - (\sum x)(\sum y)}{\sqrt{[n\sum x^2 - (\sum x)^2][n\sum y^2 - (\sum y)^2]}}
• The correlation is plotted as a histogram:
• +1 (green line) → Perfect positive correlation
• -1 (red line) → Perfect negative correlation
• 0 (gray line) → No correlation

📊 Why Use This?

This indicator helps traders identify relationships between assets, such as whether two markets move together or inversely. It is useful for hedging strategies, portfolio diversification, and market comparisons.

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.