Correlation between ^NDX and QQQ
Author: fairone99
Creation Date: 7/30/2020 4:14 AM
profile picture

fairone99

#1
Hi!

I am developing a trading strategy based on trading Nasdaq 100 Index.

Previously, I was using QQQ for strategy building and optimization as QQQ is tracking the Nasdaq 100 Index.

However, suddenly, I am thinking if I could use ^NDX directly as ^NDX is the Nasdaq 100 Index itself and has a much longer history.

QQQ has a history back to the year of 1999 while ^NDX has a history back to the year of 1985.

Ideally, using ^NDX for my strategy building and optimization will be better as it has much longer history than QQQ.

But, my question is if I would use ^NDX for my strategy building and optimize, but in fact (in the real world), I will use QQQ to make real trade, will this approach work?

QQQ is supposed to track ^NDX. But is it tracking ^NDX at 100%? If it does track ^NDX at 100%, I should be able to use the above approach (use ^NDX for my strategy building and optimization then use QQQ for real trade), right?

Does Wealth Lab Dev provide any tool to compare ^NDX and QQQ to see if they are correlated at 100% or how much they are correlated?

Could somebody shed some light on this?

Thanks!


Alex
profile picture

Eugene

#2
Hi Alex,

Of course WLD provides correlation. There are two members of Community Indicators which return Pearson's correlation, CorrelationXL and Correlation:

Correlation

They're doing the same thing - just were coded by different people.
profile picture

fairone99

#3
Thank you, Eugene!

I have used the following code sample to demo the correlation calculation:

CODE:
Please log in to see this code.


It works and it calculates correlation on CMO and RSI value of any one instrument.

However, my plan is to read two instruments (^NDX and QQQ) into a script and calculate the correlation.

Could you shed some light on how to read two instruments into a script for calculation?



Alex
profile picture

Eugene

#4
Sure thing. Here goes:

CODE:
Please log in to see this code.


Pick whichever series you want (CorrelationXL or Correlation), they're spitting out the same number.
profile picture

fairone99

#5
Excellent! Eugene...

The code that you provided works and from the output result, I am very sure that ^NDX and QQQ are very much correlated.

Thanks again!


Alex
profile picture

Eugene

#6
Any time. Alex, you might also want to adjust the Period via exposing a parameter slider to review the correlation over different time spans.
profile picture

fairone99

#7
Yes and good suggestion!

I did adjust the Period from 252 (one year) to various numbers (multiple years) to look back plus span different timeframe then calculate the correlation between ^NDX and QQQ...
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).