Advance Decline Percent

Hi,

I am working in the breadth module. I want to create the advance decline percent on a custom index of mine. I want to calculate: (advancers - decliners) / (advancers + decliners).

I went to script the advance decline percent for SPX to make sure it matched the advance decline percent that is provided with the Optuma EOD breadth data. I unfortunately cannot get them to match. I have tried a lot of ways and am now stuck. I started with the following script:

[scode lang=“{language}”] //Count advancers
V1 = CLOSE() > CLOSE(OFFSET=1) ;
//Count decliers
V2 = CLOSE() < CLOSE(OFFSET=1) ;
//Calc AD%
(V1 - V2) / (V1 + V2)[/scode]

When it did not match I started to test each piece, and so I know that in isolation the count advancers and the count decliners part of the script works properly in isolation if I set the bread action setting to count.
I know that in isolation the numerator and denominator of the Calc AD% work in when the breadth action is set to sum.
I just don’t know how to combine the entire formula.
I did try setting the breadth action to advance decline percent and entered the numerator as V1 - V2 and denominator as V1 +v2, but that did not work either.

I know you guys are busy, and I am sorry I cannot figure this out on my own with several mentions of this in the forum. Please advise on how I can manually script this for SPX so I can then use the formula on my custom index. Thank you for your help.
Louis

Hi Louis,

Set the Breadth Action in the custom breadth engine to Advance Decline Percent and use CLOSE() IsUp for the Advance Script and CLOSE() IsDown for the declines.

Thank you, Darren! This works perfectly.

Hi Darren. I have a question. Attached is picture 1. Picture 1 shows the advance and decline data for the S&P 500 as of the close on 03/09/2022. This data shows 418 advancers and 82 decliners. The net advancers are 336. The advance decline percentage becomes 67.20%. That is 336/500. They use 500 as the total issues, not sure why they drop the last few.

When I asked about determining this advance decline percentage you replied above saying: “Set the Breadth Action in the custom breadth engine to Advance Decline Percent and use CLOSE() IsUp for the Advance Script and CLOSE() IsDown for the declines.” When I do this, the result is 83.4. Please see picture 2. The 500 vs 505 is not the cause of this difference.

I am not sure what is causing such a large difference in the calculations in pictures 1 and 2. Please let me know your thoughts.

Of note, the following script with the breadth engine set to sum gets me a lot closer. Please see picture 3.

//Calc Net advancers.
V1 = CLOSE() IsUp ;
V2 = CLOSE() IsDown ;
V3 = (V1 - V2) / (V1 + V2) ;
//Calc AD% 
(V3 / 500 ) *100

thank you!

Hi Louis,

The breadth engine is currently being rebuilt as part of a wider Optuma overhaul Mathew Verdouw is working on that will see massive improvements in processing speeds and resource management (due as part of Optuma 2.2 update near the end of this year). We checked that first and confirmed the updated breadth engine is using the expected formula for Advanced / Decline %.

Unfortunately, the current breadth engine is using a different calculation which is why your results don’t match your manual calculations. We will aim to have that resolved in the 2.1 update which is in the final stages of coding before being made available for testing.

In the meantime, you can bypass the issue by creating 2 breadth codes, one that counts the number of Advances and one that counts the number of Declines.

Ex1

Once you have those breadth codes you can use a Show View to build the A/D % data with the following script:

V1 = GETDATA(CODE=SP500AD1:Market Breadth) ; 
V2 = GETDATA(CODE=SP500DEC1:Market Breadth) ; 
V3 = V1 + V2 ; 
((V1 - V2) / V3) * 100

If you want to hard code it to 500 you would adjust the script to:

V1 = GETDATA(CODE=SP500AD1:Market Breadth) ; 
V2 = GETDATA(CODE=SP500DEC1:Market Breadth) ; 
V3 = 500 ; 
((V1 - V2) / V3) * 100