OPEN-SOURCE SCRIPT

Rolling Correlation vs Another Symbol (SPY Default)

82
This indicator visualizes the rolling correlation between the current chart symbol and another selected asset, helping traders understand how closely the two move together over time.

It calculates the Pearson correlation coefficient over a user-defined period (default 22 bars) and plots it as a color-coded line:
• Green line → positive correlation (move in the same direction)
• Red line → negative correlation (move in opposite directions)
• A gray dashed line marks the zero level (no correlation).

The background highlights periods of strong relationship:
• Light green when correlation > +0.7 (strong positive)
• Light red when correlation < –0.7 (strong negative)

Use this tool to quickly spot diversification opportunities, confirm hedges, or understand how assets interact during different market regimes.

Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.