- This topic has 3 replies, 2 voices, and was last updated 8 months ago by .
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- You must be logged in to reply to this topic.
Optuma Forums › Optuma Scripting › Rolling starting date of a line
Hello,
Is it possible to set a rolling starting date for a line? See example attached:
Thank you
Marc
Hi,
Yes, you can use a combination of BarIndex(), IF() and Hidden() functions to achieve this result.
Example:
1 2 3 |
IF(BarIndex() > Last(BarIndex(OFFSET=2)), Last((High(OFFSET=1) + Low(OFFSET=1)) / 2), Hidden()) |
This is how the above would look on a chart using a Show Plot:
Thanks Matthew,
How do you define the period in this case? There is no mention of 3 months period in the formula…
best
Marc
Hi,
Your example used a quarterly chart, so I did the same. BarIndex() was used to determine how far back the line should go, in your example you were starting from the bar you took the H/L average from, which was the second last bar, so I used the offset to set that.
BarIndex() > Last(BarIndex(OFFSET=2))
All bars on a chart have a bar index, you can add BARINDEX() to a Show View to see each value. This can be used as a reference to change the range in different scripts.
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. |