Choose a Site

Call TradeStation 800.808.9336

To help us serve you better, please tell us what we can assist you with today:
Please help us serve you better!
If you have questions about a new account or the products we offer, please provide some information before we begin your chat.

If you are a client, please log in first.
* Required Fields
First Name *

Send to FacebookTweet ThisShare on Google+Email to a Friend

Understanding and Using Correlation Analysis

Related Files

Download Files 

By Frederic Palmliden, CMT

Senior Quantitative Analyst


  • Focus: Technical
  • Markets: Equities, Futures, Forex
  • Time Perspective: Short-term,
Studies/Files Included:
  • Workspaces 
  • Indicators


Correlation analysis is about observing the interaction of various securities and markets. Since these relationships are dynamic, it is useful to measure them historically and to monitor them in real time. For example, this analysis may be useful in revealing which securities in a portfolio provide diversification and which may be duplicating unwanted risk. Here, two custom indicators are used to highlight inter-market relationships.


Figure 1 – Futures Continuous Contracts (@ES and @CL) with the TSLabs: CoeffR Indicator


Pearson’s correlation coefficient between two variables is defined as the covariance of the two variables divided by the product of their standard deviations:


“In the world of finance, correlation is a statistical measure of how two securities move in relation to each other. Correlation is computed into what is known as the correlation coefficient, which ranges between -1 and +1. Perfect positive correlation (a correlation coefficient of +1) implies that as one security moves, either up or down, the other security will move in lockstep, in the same direction. Alternatively, perfect negative correlation means that if one security moves in either direction the security that is perfectly negatively correlated will move in the opposite direction. If the correlation is 0, the movements of the securities are said to have no correlation; they are completely random. In real life, perfectly correlated securities are rare; rather, you will find securities with some degree of correlation" (Investopedia 2012).


TSLabs: CoeffR Indicator Description

The first custom indicator presented in this paper is the “TSLabs: CoeffR indicator,” which graphically depicts Pearson’s product moment correlation coefficient R, also known as the “coefficient R.”  Due to price variability among securities, it soon becomes apparent that the line tracking the coefficient R is quite volatile even when the length of the look-back period is large – for example, 120 days, or roughly six months of data. Therefore, it might be useful to use percentage moves instead of price moves. Using daily percentage moves instead of daily prices as inputs for the coefficient R function smoothes out the coefficient R line dramatically (see the blue histogram versus cyan line in Figure 1). Both methods have advantages and disadvantages that will be discussed shortly. The different inputs for the TSL CoefficientR indicator are described in Table 1.

The files for the CoeffR indicator are available in the TradingApp Store.


Table 1 – CoeffR Inputs
Input Name Input Value Input Description
 CorrLength_Price 120 Look-back length for the coefficient R based on price moves 
 CorrLength_Perc 120 Look-back length for the coefficient R based on percentage moves, e.g., daily percentage moves 
 CoeffR_Price TRUE Boolean value (True/False) to show the coefficient R based on price moves 
 CoeffR_Perc TRUE Boolean value (True/False) to show the coefficient R based on percentage moves
 CoeffR_PriceColor Cyan Color for the coefficient R based on price moves
 CoeffR_PercColor Blue Color for the coefficient R based on percentage moves
 RefLinesColor Black Color for the reference lines (+1, -1, and 0 lines)

CoeffR Analysis

The main advantage of using the price moves is that the CoeffR line will usually reflect a change in correlation faster than the coefficient R based on percentage moves, assuming the same look-back length. An example is provided below in Figure 2, where the euro currency and crude oil became highly positively correlated for many months in the beginning of 2007. Notice how the CoeffR_Price line (cyan line) increased sharply towards +1, while the CoeffR_Perc line (blue histogram) reflected an uncorrelated reading during the same period before finally increasing around the end of 2007. Therefore, depending on the application, it may be adequate to have a shorter look-back length for the CoeffR_Perc versus that for the CoeffR_Price, to identify correlation changes quicker.


While the point above may be a disadvantage for the CoeffR_Perc for some applications, it may be an advantage for other applications. For instance, when researching longer-term correlations among securities within a portfolio, it might be useful to use the correlation coefficient based on percentage moves, since the concern may not be short-lived correlation shifts, but rather sustainable relationships. 

Figure 2 – Futures Continuous Contracts (@ES and @CL) withthe TSLabs: CoeffR Indicator (2006-2008 )


The ability to view the correlation between two securities across a large time frame is a definite benefit of the CoeffR indicator. However, when numerous securities are considered, a matrix form is preferred, especially when comparing current correlation coefficient values. 


TSLabs: Correlation Matrix Indicator Description

The second custom indicator presented in this paper is the “TSLabs: Correlation Matrix” indicator for RadarScreen®, which displays the coefficient R values for all of the two security combinations from the first column of symbols in a RadarScreen window (see Figure 3). Notice that the same securities are listed in the first column and in the first row. Notice also that the securities are listed in the same order. Thus, the Matrix includes a diagonal with perfect positive correlation values (R = 1), since those cells reflect the correlation of each security against itself. The Correlation Matrix in its current form is designed to include a total of 10 different symbols. If applicable, a benchmark for the different securities, such as SPY for stocks or sectors, may be used in the last row and in the last column for reference purposes.


The symbols used may be changed by changing the symbols in the first RadarScreen column (Symbol column) and changing the input symbols on the indicator’s Format Indicator - Inputs tab. However, the plot names containing the symbols are embedded in the EasyLanguage® (line 228 through 237) and will not change automatically. In addition, decreasing or increasing the number of symbols used in the indicator requires additional work in EasyLanguage.


The date for the different correlation coefficient values can be specified as an input and is displayed in the last column of the indicator in the RadarScreen window for reference purposes. One can monitor current values by typing “Today” as the input.


The coefficient R for each pair of securities may be based on price or percentage moves, as in the CoeffR indicator for charting; however, in this case, only one approach may be used at a time. The choice of method is determined by the CoeffR_Price_Or_Perc input (1 for correlation values based on price moves, 2 for correlation values based on percentage moves).


When using a large look-back length for the coefficient R values, it may be necessary to adjust the amount of data loaded into the RadarScreen window. To adjust the amount of data, specify the number of bars to load on the General tab of the Format Indicator dialog. The field is titled, “Load additional data for accumulative calculations.”  Notice that the field needs to be checked in order to edit the additional bars to load.


The different inputs for the TSL CoefficientR indicator are described in Table 2.


The files for the Correlation Matrix indicator are provided for free with the paper.


Correlation Matrix Analysis


Table 2 – Correlation Matrix Inputs
Input Name Input Value Input Description
  iSymbol1 XLY First RadarScreen column symbol
  iSymbol2 XLP Second RadarScreen column symbol
  iSymbol3 XLE Third RadarScreen column symbol
  iSymbol4 XLF Fourth RadarScreen column symbol
  iSymbol5 XLV Fifth RadarScreen column symbol
  iSymbol6 XLI Sixth RadarScreen column symbol
  iSymbol7 XLB Seventh RadarScreen column symbol
  iSymbol8 XLK Eighth RadarScreen column symbol
  iSymbol9 XLU Ninth RadarScreen column symbol
  iSymbol10 SPY Correlation as of date in "MM/DD/YYYY" format, e.g., "05/06/2010" = May 6, 2010, or "Today" = current date
  TargetDate Today Look-back length for the coefficient R based on price moves
  CorrLength_Price 120 Look-back length for the coefficient R based on percentage moves, e.g., daily percentage moves
  CorrLength_Perc 120 Look-back length for the coefficient R based on percentage moves, e.g., daily percentage moves
  CorrR_Price_Or_Perc 1 1 = coefficient R based on price moves 2 = coefficient R based on percentage moves
  PerfCorrFont White Font color for perfectly correlated securities (R = 1)
  PerfCorrBG Blue Background color for perfectly correlated securities (R = 1)
  HighCorrColor Dark Magenta Color for highly positively correlated securities (R > -0.75)
  LowCorrColor Dark Magenta Color for highly negatively correlated securities (R < -0.75)


The main advantage of using the Correlation Matrix is the ability to view coefficient R values for a large number of symbols in the same window as of a specified date. In Figure 3, the coefficient R values are calculated as of May 6, 2010, which was the date of the 2010 “Flash Crash.”  Changing the specified date in the inputs tab around this particular day reveals dramatic shifts in correlation. For instance, Financials (XLF) and Utilities (XLU) had a coefficient R value of 0.10 on May 4, 2010 (price-based coefficient R and look-back length of 21), and the value jumped to 0.91 by May 20, 2010, which is to say that the pair went from being uncorrelated to highly correlated very rapidly. Other sectors had similar shifts in correlation during the same time period (see Figure 4).


Figure 3 – S&P Sector ETFs with the TSLabs: Correlation Matrix Indicator (as of May 6, 2010)
Figure 4 – S&P Sector ETFs Coefficient R Values Around the 2010 Flash Crash


The previous example highlights the fact that correlations can change rather quickly under special circumstances. During normal market conditions, however, correlation analysis usually reveals which securities provide diversification, or duplicate risk, on a consistent basis. For instance, an equity investor may be surprised to see how correlated certain equities are in his or her portfolio. In such a case, a low level of diversification is achieved within the equity allocation and the investor may want to rethink current holdings. Adding uncorrelated equities could generate risk-reducing benefits. The idea here is that the positive performance of some positions will counter the negative performance of other positions. Additionally, pairs of securities that are negatively correlated may further reduce risk. Pairs trading can take many forms and this would be just one possible approach. Also keep in mind that, in practice, negatively correlated equities are hard to find and other asset classes may need to be considered, which brings us to the next point.


The Correlation Matrix can include securities of any type. The process to update the securities is outlined above. The Correlation Matrix in Figure 5 includes the main forex pairs as of March 15, 2012. In this particular case, the “CoeffR_Price_Or_Perc” input is set to 2 for coefficient R values based on percentage moves and the look-back length is set to 120. By using these settings, notice that the EURGBP is uncorrelated to the GBPUSD, while the EURUSD has a nearly perfect positive correlation with the USDCHF. Changing to coefficient R values based on price moves and/or changing the look-back length would affect all values displayed by the Correlation Matrix indicator. A shorter look-back length would, for example, capture the more recent correlation, while de-emphasizing the historical relationship.  


Figure 5 – Forex Pairs with the TSLabs: Correlation Matrix Indicator (as of March 15, 2012)



Correlations between securities are often mistakenly assumed to hold during different market conditions. Certain securities can at times be highly positively or negatively correlated for only a season. Some of these relationships tend to be cyclical for some securities, such as @CL versus EURUSD. Other relationships tend to persist over time, such as the Dollar index versus the 3-Month UST/3-Month Euro implied differential spread. Once analysis has been performed for a particular relationship, different predictions may be made, with probabilities, as to how long a relationship may be expected to hold or how long divergence is expected to continue before positive or negative correlation resumes. These findings can then serve as grounds for mean-reversion as well as trend-following strategies.

Works Cited

Investopedia. Correlation. March 21, 2012. (accessed March 21, 2012).



To use the files provided with this issue of Analysis Concepts:

  • Files with extension ".eld" – These contain EasyLanguage® documents: analysis techniques and strategies. Double-clicking on this file will start the EasyLanguage Import Wizard. Follow the prompts to completion. The analysis techniques or strategies will automatically be placed in the correct locations for your use in TradeStation. This should be done before opening any workspaces provided.
  • Files with extension ".tsw" – These are TradeStation workspaces. These may be stored in any folder where you choose to save TradeStation workspaces.
  • Files with extension ".txt" – These are text versions of the EasyLanguage documents and are generally used only by advanced EasyLanguage users.
  • Other supporting documents or files may also be attached to the report.


Questions or comments? Contact us at