Average of all stocks below their 252-day highs as a breadth tool

Optuma Forums Optuma Scripting Average of all stocks below their 252-day highs as a breadth tool

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #67545
    Louis
    • Topics: 38
    • Replies: 65
    • Posts: 103

    Hi,

    In a watchlist I have calculated the distance of each S&P 500 stock from its 252-day closing high with the following script:

    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:

    Please advise on the way to show this average value from the watchlist in a breadth tool. Thank you as always.

    #67550
    Matthew
    • Topics: 5
    • Replies: 631
    • Posts: 636

    Hi,

    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.

    Ex2

    #67551
    Louis
    • Topics: 38
    • Replies: 65
    • Posts: 103

    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,

    #67558
    Matthew
    • Topics: 5
    • Replies: 631
    • Posts: 636

    Hi,

    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.

    Ex3

    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.

    1 user thanked author for this post.
    #67561
    Louis
    • Topics: 38
    • Replies: 65
    • Posts: 103

    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.

    #67562
    Matthew
    • Topics: 5
    • Replies: 631
    • Posts: 636

    Hi,

    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.

    #67563
    Louis
    • Topics: 38
    • Replies: 65
    • Posts: 103

    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.

    1 user thanked author for this post.
    #67567
    Thomas
    • 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:

    Any idea about this issue?

    Thanks and best wishes,
    Thomas

    #67569
    Thomas
    • Topics: 130
    • Replies: 176
    • Posts: 306

    Hi Louis,

    perhaps the following breadth script is something you are interested in:

    Here is a screenshot of my Breadth module settings:
    screenshot - 0000

    I think the above scripts are perhaps better suited for what you are looking for.

    Best wishes,
    Thomas

    #67577
    Matthew
    • Topics: 5
    • Replies: 631
    • Posts: 636

    Hi Thomas,

    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…

    Here’s a comparison of the above script using Historical vs Current memberships (Historical is Blue, Current is Green):

    Ex13

    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.

    1 user thanked author for this post.
Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.

Pin It on Pinterest