February 22, 2022 at 6:19 am #67545
In a watchlist I have calculated the distance of each S&P 500 stock from its 252-day closing high with the following script:12345V1 = HIGHESTHIGH(CLOSE(), BARS=252, INCBAR=True) ;V2 = CLOSE() ;100 * ((V2 - V1) / V1)
In the watch list summary row, I selected average above this script column. This is showing the average of all of the 505 stocks are below their 252-day closing highs. Please see attached picture 1.
I want to plot this average value, the average that all stocks are below their 252-day highs, in a breadth tool. I cannot figure out the correct script. I set the breadth action setting to sum and tried to normalize the formula but it doesn’t match the watchlist value:12345V1 = HIGHESTHIGH(CLOSE(), BARS=252, INCBAR=True) ;V2 = CLOSE() ;(100 * ((V2 - V1) / V1)) / 505
Please advise on the way to show this average value from the watchlist in a breadth tool. Thank you as always.
February 22, 2022 at 7:52 am #67550
- This topic was modified 7 months ago by Louis Spector.
You would use the same script as you did on the Watchlist:
V1 = HIGHESTHIGH(CLOSE(), BARS=252, INCBAR=True) ;
V2 = CLOSE() ;
100 * ((V2 – V1) / V1)
There’s no need to account for the number of symbols, the Breadth manager will do that automatically.
Set the Breadth Action to Average and the value generated should match the summary row of the Watchlist.February 22, 2022 at 8:29 am #67551
Hi Matthew. This is what I tried originally, but the values do not match.
The value from the watchlist is 8.41%.
The value from the breadth tool is 16%.
This discrepancy is because in the breadth engine, the average setting divides the result of the script by the total amount of items being checked. 8.41/505 = 16. Please see pictures 1, 2 and 3 attached.
thank you,February 22, 2022 at 8:52 am #67558
I can’t work out how you’ve produced a value of -8.41 on the WL summary. When I use the same script between Breadth and WL Average, the values both show -16.074.
If you open the attached WL do you see the same value?
If you do, please attach your workbook for review, or email a copy to [email protected] if you do not want to make the file available publically.February 22, 2022 at 9:52 am #67561
Thank you. You workbook looks great. I went back and crated a new watchlist and the average changed to the 16% value. Not sure why this happened, but you saw the picture. I did not change the script, just started a new watchlist.
I am very happy this is now working properly. I am just a little confused. The knowledge base says: “Average – Based on the Sum above, this one divides the result by the total number of members to get an average each day.” https://help.optuma.com/kb/faq.php?id=644. When does this setting perform the division?
Thank you.February 22, 2022 at 12:46 pm #67562
Glad it’s working now. Not sure where the other value came from, I went through all the options, only thing i can think is it calculated before an EOD update had finished so it was incomplete data, i will need to test further to see if i can replicate.
For your second question, i think it is working as described.
The sum on the WL column is -8,117.3555, divided by the 505 members currently in the list the average value comes to -16.07, matching the breadth and average value produced by the WL header row.February 22, 2022 at 12:50 pm #67563
Thank you so much for explaining that. You are a smart guy. Don’t waste too much time checking into it. My computer is old and has poor computing power. I get glitches all of the time where Optuma tells me I have run out of memory and there is this or that error requiring a restart. Thanks again.February 23, 2022 at 5:17 am #67567Thomas
- Topics: 130
- Replies: 176
- Posts: 306
Hi Darren and Louis,
I have a question about the “ISMEMBER()” function in the script for the breadth module. Darren, you wrote in another threat that the “ISMEMBER() function only works with true/false conditions, not when calculating averages.”
In the above breadth scripts we calculate averages so the ISMEMBER() makes no sense.
There is now my question/issue: If I set the breadth module property “Membership” to “Current” the historical results are the same as when I set it to “Historical”. If I add the ISMEMBER() function to the breadth script, the results are completely wrong.
But that shouldn’t be the case in my opinion. When I set it to “Historical” and would use/could use the function ISMEMBER() the historical results of the script should be different than setting it to “Current”.
By the way, the same problem occurs when I calculate the average drawdown using the following script:1234// 52 Week DrawdownDDP(BACKTYPE=Weeks, LOOKBACKBARS=52)
Any idea about this issue?
Thanks and best wishes,
ThomasFebruary 23, 2022 at 6:46 am #67569Thomas
- Topics: 130
- Replies: 176
- Posts: 306
perhaps the following breadth script is something you are interested in:12345678// S&P 500 Members >= 10% below 52-Week HighVar1 = HIGHESTHIGH(CLOSE(), BARS=52, INCBAR=True, BACKTYPE=Weeks) ;Var2 = CLOSE() ;Var3 = ((Var2 - Var1) / Var1) * 100 ;Var4 = Var3 <= -10 ;Var41234// Stock is Member of S&P 500ISMEMBER(SYMBOLLIST=S&P 500)
Here is a screenshot of my Breadth module settings:
I think the above scripts are perhaps better suited for what you are looking for.
ThomasFebruary 23, 2022 at 11:44 am #67577
I believe you can use ISMEMBER() in an Average based breadth, but it needs to be setup differently. In this example the script would be modified to include ISMEMBER this way…1234567V1 = HIGHESTHIGH(CLOSE(), BARS=252, INCBAR=True) ;V2 = CLOSE() ;V3 = 100 * ((V2 - V1) / V1);V4 = ISMEMBER(SYMBOLLIST=S&P 500) ;IF(V4 == 1,V3,0)
Here’s a comparison of the above script using Historical vs Current memberships (Historical is Blue, Current is Green):
You can see the lines are pretty identical near the recent price action, but differs more and more the further back the breadth goes, as memberships change.
- You must be logged in to reply to this topic.