- This topic has 2 replies, 3 voices, and was last updated 1 week ago by .
Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.
Optuma Forums › Optuma Scripting › Close Value Three Months Ago
Hi,
I have the following simple script:
1 2 3 4 5 6 7 8 |
// Get S&P 500 Data Line1 = GETDATA(CODE=SPX:WI) ; // Calculating the Tool Line2 = CHANGE(Line1, INT_TYPE=Month, INT_COUNT=3) ; Line2 |
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
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.
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.
Cookie | Duration | Description |
---|---|---|
cname | 14 days | This cookie is set by Optuma. The cookies is used to store the users campaign selection for selecting the correct version of Optuma to trial and is "Necessary". |
cookielawinfo-checbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
cookielawinfo-checbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
cookielawinfo-checbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |