Rolling starting date of a line

Optuma Forums Optuma Scripting Rolling starting date of a line

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #66849
    Marc
    • Topics: 16
    • Replies: 25
    • Posts: 41

    Hello,

    Is it possible to set a rolling starting date for a line? See example attached:

    Thank you
    Marc

    #66852
    Matthew
    • Topics: 5
    • Replies: 521
    • Posts: 526

    Hi,

    Yes, you can use a combination of BarIndex(), IF() and Hidden() functions to achieve this result.

    Example:

    This is how the above would look on a chart using a Show Plot:

    Ex4

    #66861
    Marc
    • Topics: 16
    • Replies: 25
    • Posts: 41

    Thanks Matthew,

    How do you define the period in this case? There is no mention of 3 months period in the formula…

    best
    Marc

    #66864
    Matthew
    • Topics: 5
    • Replies: 521
    • Posts: 526

    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.

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

Pin It on Pinterest