Counting Stocks in Breadth Module

Good morning,

I am trying to create a fairly simple breadth output, but keep running into issues with how the breadth module works.

I am seeking to take that historical S&P 500 and take a count of the number of stocks up ( then summed over 5 days) as a ratio of the count of the number of stocks down (summed over 5 days).

My module inputs are:
image

My Advance Script is:

Advancing = CHANGE() > 0;
Advancing5 = BARSTRUE(Advancing, RANGE=Look Back Period, BARS=5);
Advancing5

My Decline Script is:

Declining = CHANGE() < 0;
Declining5 = BARSTRUE(Declining, RANGE=Look Back Period, BARS=5);
Declining5

I get the below result, which is not accurate

The result is creating a negative number, but the two results must be positive, meaning the lowest the ratio can go is 0, not negative.

What could I be doing wrong?

Many thanks,

EK

Hi Eric,

Rather than building your own breadth you can use our breadth data (SPX-A for daily advances and SPX-D for declines).

To calculate the 5 day ratio use the following:

//Get the daily advance and decline values;
Adv1=GETDATA(CODE=SPX-A.OB:BD);
Dec1=GETDATA(CODE=SPX-D.OB:BD);
//Calculate 5 day ratio;
ACC(Adv1, RANGE=Look Back Period, BARS=5) / ACC(Dec1, RANGE=Look Back Period, BARS=5)

So the current ratio is 0.49 ie over the last 5 days there have been half as many advancing stocks as declining:

Thanks Darren, this is certainly an easier solution.

However, I only get data to June. How far back will this go?

It looks like the underlying Breadth Data hasn’t been downloaded to your system. If you open a chart of SPX-A or SPX-D how much data do you have? It should go back to 1998 for SPX and 2017 for R3K.

To make sure you have all the data, click on Data > Exchanges > Breadth Data and select Import EOD Data History. Once complete, reopen your chart and the historical ratio should be calculated.

1 Like

Was looking at this and trying to reproduce it but I don’t see Data/Exchanges/Breadth Data as an option. Is this not a standard feature in the Enterprise Edition? Thanks.

BTW, Happy New Year!

Hey Terry - the Breadth data has been added to your account and will be available when you next log in. See here for details on what’s included:

A workbook example using the data can be downloaded from here: