Skip to content
All library documents

Rolling Correlation Matrix for Six User-Selected Markets

Article TradingView scripts

Summary

This indicator displays pairwise correlations among six selected symbols using closing prices over a user-defined look-back window. It retrieves each series on a chosen timeframe, stores recent values in arrays, and calculates correlation from covariance divided by the two series' standard deviations. The resulting matrix is labeled with the symbols on both axes.

Color bands classify correlations from negative through weak to increasingly positive, with thresholds and colors adjustable by the user. The author explains that the array-based calculation was chosen because the built-in correlation function did not behave consistently inside a loop in the relevant Pine Script context. The document provides implementation details, not empirical findings or a trading strategy. It calculates correlation on price levels rather than explicitly on returns, so users should consider trends and nonstationarity when interpreting the displayed relationships.

Key ideas

  • The script estimates every pairwise correlation among six configurable symbols.
  • It derives correlation from array covariance and standard deviations over a selected look-back window.
  • Users can choose the timeframe, symbols, classification thresholds, and display colors.
  • The matrix is intended as an indicator display and offers no evidence that correlations predict future returns.
  • Correlation based on price levels can be influenced by trends and should be interpreted cautiously.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.