Close Value Three Months Ago

Optuma Forums Optuma Scripting Close Value Three Months Ago

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #68243
    Thomas
    • Topics: 124
    • Replies: 157
    • Posts: 281

    Hi,

    I have the following simple script:

    This simple script calculates the rolling three-month percentage change.

    Now I want to create two “Chart element” tools. One should display the closing reference value of the above calculation and the other should display the date of the closing reference value.

    I have tried a number of “settings” using the OFFSET() and VALUEWHEN() functions, but never got what I wanted. In most cases I tried, I got the closing value at the end of February.

    BUT since the CHANGE() function is a rolling percentage calculation, I need the closing value from 02/11/2022 and not the closing value at the end of February if the calculation is made with closing value from 05/11/2022.

    Using the S&P 500 closing value from 05/11/2022 which is 3935.18, the correct reference values would be 02/11/2022 and 4418.64.

    Any help would be greatly appreciated.

    Best wishes,
    Thomas

    #68258
    Matthew
    • Topics: 5
    • Replies: 609
    • Posts: 614

    Hi,

    There’s no simple way to do this currently, but in the upcoming v2.1 update the Offset() function is adding an option to swap between a BAR offset and a CALENDAR DAY offset.  Once this is available the script should be straight forward.

    1 user thanked author for this post.
    #68263
    Darren
    • Topics: 70
    • Replies: 790
    • Posts: 860

    If the Chart Element is placed on a daily chart then your script will look 3 months back from the last bar ie to Feb 11th from May 11th. If the chart timeframe is monthly, then only the open, high, low, and closing values for the month are loaded in to the chart, which is possibly why you are seeing the change from the close of February.

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

Pin It on Pinterest