Fix Starting Point for Calculation

Optuma Forums Optuma Scripting Fix Starting Point for Calculation

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #62629
    Thomas
    • Topics: 130
    • Replies: 176
    • Posts: 306

    Hi,

    I want to calculate a breadth indicator using the S&P 500 Advancing and Declining issues with a fixed starting point.

    The calculation is the following:
    Suppose the oscillator stands at 100 at yesterdays close.
    Suppose today there are 220 advancing issues and 385 declining issues of the S&P 500.

    The calculation for yesterday was: N(yesterday) = 100;
    N(today) = (0.9 * N(yesterday)) + (0.1 * (Advances(today) – Declines(today))

    using the data from the above example:
    N(today) = (0.9 * 100) + (0.1 * (220 – 385) =  73.5

    My script above is wrong because of the starting point. Var3 has to be a “different one” but I don’t know what is the right code.

    Any help is very appreciated.

    Thanks
    Thomas

    • This topic was modified 1 year ago by Thomas.
    #62683
    Mathew
    • Topics: 40
    • Replies: 2,021
    • Posts: 2,061

    Hi Thomas,

    The value of 100 is not needed.

    Optuma will sort out the first value. You can use BarIndex to do an IF() and do a special case when it is 0, but it should not be necessary.

    Hope that helps.
    Mathew

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

Pin It on Pinterest