CQG Primer: Correlation Function

Thom Hartle – July 10, 2025

This function is available in the Add Study window and in the Formula Toolbox.

The function measures the strength and direction of the price movement of two symbols over a defined number of bars. For example, CORREL(CLE,QO,10) returns the correlation between West Texas Crude on the NYMEX and North Sea Brent on the IPE over the last 10 bars on the chart. Another variation on the correlation study is the following: CORREL(@,EP,10) which correlates any symbol on the chart with the E-mini S&P 500 Index over the last 10 bars.

f1

The above chart displays Crude Light (green) versus Emini S&P 500 (blue) on an Analog chart. The study is the correlation function using a 10-period look comparing the two markets. There are times when the two market are positively correlated and times when the two markets are negatively correlated.

The CQG correlation function uses Pearson's correlation coefficient.

The Pearson correlation coefficient, often denoted as r, measures and quantifies the strength and direction of a linear relationship between two variables. The output ranges from +1 to -1, where:

  • Values near +1 indicate a perfect positive linear correlation. If one variable increases, the other increases proportionally.
  • Values near 0 indicate no linear correlation.
  • Values near -1 indicate a perfect negative linear correlation. If one variable increases, the other decreases proportionally.

The correlation does not denote cause and effect. Also, the statistical measure is for variables that are normally distributed (on a graph the distribution of data appears as a bell curve). Market prices are not normally distributed. Market price distributions have fat tails and are often skewed.

CQG (Correl) is a function and is found under the Functions list in Help.

f2

There are six custom studies that use the Correl Function.

f3

The CorrFX^ custom study produces three curves: DXC, EUR, and JPY.

f4

This display below is when applied to a chart. The "@" sign in the formula indicates the function is applied using the symbol for the chart and the symbol supplied in the function's formula. The "PERIOD" is a parameter.

f5

To create a custom study:

Defining a custom study involves entering the following:

  • A Study Name
  • A Study Name Abbreviation (if desired)
  • Study Curve Names (instead of the c1, c2, c3, and so forth, default names)
  • Study Curve Formulas

Here are the steps:

  1. Click the New button in the Study Names group on the Custom Studies tab in Formula Builder.
  2. Enter a study name. The system automatically enters an abbreviation, but you can Enter a study abbreviation, if you want to.
  3. Click on the New Study Abbrev and Curve Name box and enter no more than 7 characters. The custom study abbreviation must start with a letter rather than a number or symbol. CQG uses the abbreviation name when you use one custom study as the basis for another custom study.
  4. Click the OK button.

Below, a Correlation custom study using Bitcoin (Symbol: BTC) is added to a chart of the E-mini NASDAQ 100 contract.

f6

The Correlation function is available as an RTD Excel formula.

=RTD("cqg.rtd",,"StudyData", "Correlation(CLE,EP,Period:=20,InputChoice1:=Close,InputChoice2:=Close)", "Bar", "", "Close",30,"0", "all","", "","True","T")/100
  • First Symbol: CLE
  • Second Symbol: EP
  • Lookback Period: 20
  • Input Choice1: Close
  • Input Choice 2: Close
  • Chart Type: Bar
  • Time Frame: 30
  • Bar Lookback: 0 (the current bar)

A sample spreadsheet is available at the bottom of the post.

f7

There are numerous posts on Workspaces using correlation analysis as the basis for the Excel dashboards and one PAC for a CQG IC/QTrader page.

And one for analysis of correlation relationships.

Requires CQG Integrated Client or CQG QTrader, and Excel 365 or more recent.

Downloads

Disclaimer

Trading and investment carry a high level of risk, and CQG, Inc. does not make any recommendations for buying or selling any financial instruments. We offer educational information on ways to use our sophisticated CQG trading tools, but it is up to our customers and other readers to make their own trading and investment decisions or to consult with a registered investment advisor. The opinions expressed here are solely those of the author and do not reflect the opinions of CQG, Inc. or its affiliates.