HIGHESTHIGH function reference a variable for look back period

Optuma Forums Optuma Scripting HIGHESTHIGH function reference a variable for look back period

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #66157
    Tommy
    • Topics: 1
    • Replies: 2
    • Posts: 3

    Hello,

    I’m trying to find the highest high since a new 13 week low was created. The date of the 13 week low will only change when the low of the current bar is less then the previous 12 weeks. I want to use the date of the 13 week low bar as a variable and use the HIGHESTHIGH function to find the highest high since the date of the 13 week low.

    Is it possible to reference a variable in the HIGHESTHIGH function? Below is what I have done so far but script is not valid for H1.

    #66162
    Matthew
    • Topics: 5
    • Replies: 430
    • Posts: 435

    Hi,

    The following script could work, but it’s only valid for current data (ie you can’t scan for historical instances).

    In this example, V1 looks for the new 13 Week Low being set. $a looks for the number of bars since the new low was set, and the Highest High function references this count and sets the back bars accordingly.

    In the image below you can see on ASX the last 13 week low was 144 bars ago. The Highest High (blue) line is using a lookback period of 144 bars.

    Ex2
    If you enabled training mode and started hiding bars, the Highest High line would adjust based on the $a variable count.

    1 user thanked author for this post.
    #66167
    Tommy
    • Topics: 1
    • Replies: 2
    • Posts: 3

    Hi Matthew,

    Thank you for your reply. That works fine. I see what you mean, it’s only valid for current data. Is it possible to view historical instances from current data instead of using training mode?

    Using the show plot like you have done above, when there is a new a new 13 week low the HighestHigh would reset to the high of the bar that created a new 13 week low. It would gradually step up when there are new highs until a there is new 13 week low where it would reset again.

    Thank again
    Tom

    #66172
    Matthew
    • Topics: 5
    • Replies: 430
    • Posts: 435

    Hi,

    The following alternative script should work on a historical basis as well (no need for Training Mode)…

    1 user thanked author for this post.
    #66173
    Tommy
    • Topics: 1
    • Replies: 2
    • Posts: 3

    Hi Matthew.

    Thanks for that. That seems to works fine.

    Kind regards
    Tom

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Pin It on Pinterest