Problem with rule for costum universe

Hi all,

I would like to create a custom universe which counts the number of stocks with a certain correlation to the S&P 500. When I try the following rule…

UnivCnt(“Correl(1,62,GetSeries(”$SP500"))>0.3")

… I get this error message in return when creating the chart:

Aborted! ERROR: In Rule 1: Error near ‘$SP500"’: Invalid command ‘$SP500"’

It somehow looks as if the syntax of the double quotes is not understood correctly.

Any advice is appreciated :slight_smile:

You cannot have double quotes within double quotes.
Currently, if you want to use $SP500 there, you must use our internal number for it:

UnivCnt("Correl(1,62,16864)>0.3")

This number can be seen by running this rule in the screener and viewing the “Screen Factors” report:

Ticker("IBM") And ShowVar(@x, GetSeries("$SP500"))

Thanks, Aaron!

This would work too if your benchmark is the S&P500

UnivCnt(“Correl(1,62,#Bench)>0.3”)