Breadth Script: Rolling 3 Month Performance

Hi,

I have a watchlist for the S&P 500. Please see picture 1 attached.

The first column is the 13-week ROC for each symbol.
The second column is the 13-week ROC for SPX.
The third column is Column1 - Column2. The result is > 0 when the symbol has outperformed SPX on a rolling 13-week basis.

Using the breadth engine, I want to count the number of symbols where the third column is > 0. I have tried several scripts, but none generate the 160 number to match the watchlist. Please help. Thank you.

Here are two attempts:
1

//Component Rolling 3-month ROC 
V1 = ROC(BARS=13)/100 ; 
//SPX Rolling 3-month ROC 
V2 = GETDATA(TIMEFRAME=1 Week, CODE=SPX:WI) ; 
V3 = ROC(V2, BARS=13)/100 ; 
//Is Relative Rolling 3-month ROC > 0? 
V4 = V1 - V3 ; 
V5 = IF(V4>0, 1, 0) ; 
V5 == 1

2

//Component Rolling 3-month ROC 
V1 = ROC(BARS=13)/100 ; 
//SPX Rolling 3-month ROC 
V2 = GETDATA(TIMEFRAME=1 Week, CODE=SPX:WI) ; 
V3 = ROC(V2, BARS=13)/100 ; 
//Is Relative Rolling 3-month ROC > 0? 
V4 = V1 - V3 ; 
V4 > 0

What about something like this… I tested it against a screen in Bloomberg and get the same results.

ROCExample.png

Hi Optuma team. I would like to follow up on this topic please. I am trying to create a breadth script to count the number of S&P 500 components which have outperformed the index over the last rolling 13 weeks.

I was hoping the following script would do it, with the breadth action set to Count, but something is not correct. Please advise. Thank you.

//Component Rolling 3-month ROC 
V1 = ROC(BARS=13)/100 ; 
//SPX Rolling 3-month ROC 
V2 = GETDATA(TIMEFRAME=1 Week, CODE=SPX:WI) ; 
V3 = ROC(V2, BARS=13)/100 ; 
//Is Relative Rolling 3-month ROC > 0? 
V4 = V1 - V3 ; 
V4 > 0

What appears to be off the number of stocks? If I take your code through yesterday (5/1/23) I get 166 stocks in both the Scan and Breadth Function with the attached settings. If you could elaborate it might be an easy fix…

Hi Duke. Thanks for helping. I like your idea of using the scanning manager. Tonight my watchlist says there are 164 stocks outperforming SPX looking back 13-weeks, see picture 1. The same is true for the scan with the same script. The breadth engine counts 189, which is different than the watchlist and scan. See picture 2.

The 164 result is generated using the following script. It scripts a 1 if the 13-week ROC is greater than SPX’s. It counts 164:

//Component Rolling 3-month ROC 
V1 = ROC(BARS=13)/100 ; 
//SPX Rolling 3-month ROC 
V2 = GETDATA(TIMEFRAME=1 Week, CODE=SPX:WI) ; 
V3 = ROC(V2, BARS=13)/100 ; 
//Relative Rolling 3-month ROC 
V4 = V1 - V3 ; 
IF(V4>0, 1, 0)

The 189 result is generated using the following script in the breadth engine. It counts 189:

//Component Rolling 3-month ROC 
V1 = ROC(BARS=13)/100 ; 
//SPX Rolling 3-month ROC 
V2 = GETDATA(TIMEFRAME=1 Week, CODE=SPX:WI) ; 
V3 = ROC(V2, BARS=13)/100 ; 
//Is Relative Rolling 3-month ROC > 0? 
V4 = V1 - V3 ; 
V4 > 0

Looking forward to your thoughts.

Well, HMMM… not sure what is going on… I get the same 164 securities on the scan and the breadth. I thought it might be because you were using Historical Constituents but I get the same number using either Historical or current so that doesn’t appear to be the issue. Just out of curiosity, you might try re-downloading the Indices and Equity data files under Exchanges. I had some issues with my data files and that solved some irregularities in my data I was seeing in scans and watchlist columns. It might not solve the issue but it would be the first place I would start. I will ponder this some more…

//Component Rolling 3-month ROC 
V1 = ROC(BARS=13)/100 ; 
//SPX Rolling 3-month ROC 
V2 = GETDATA(TIMEFRAME=1 Week, CODE=SPX:WI) ; 
V3 = ROC(V2, BARS=13)/100 ; 
//Is Relative Rolling 3-month ROC > 0? 
V4 = V1 - V3 ; 
V4 > 0

Yes! Duke, thank you! I downloaded the exchange data manually as you suggested, and now the breadth tool counts 164. Problem solved. I am so happy. Thank you again.

[postquote quote=70911]

Louis, great to hear! Chasing down those issues can drive you nuts sometimes! Been down that path alot!