Was the previous bar a 13-week closing high?

Optuma Forums Optuma Scripting Was the previous bar a 13-week closing high?

  • This topic has 4 replies, 2 voices, and was last updated 1 week ago by Louis.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #70227
    Louis
    • Topics: 40
    • Replies: 69
    • Posts: 109

    Hi,

    Today is Tuesday, so looking at weekly price bars the previous bar is the last full week of data. I want to know if last week’s price bar printed a 13-week closing high using a watchlist.

    To know if the current bar is a 13-week closing high we can use the script:

    I want to know about the last bar though, so I tried using the offset function thinking “is the previous bar >= to the 13-week closing high as of the previous bar”:

    This does not work. I tried a bunch of other scripts as well. Please let me know the best script to ask if the previous bar’s close was a 13-week closing high when it closed. Thank you.

    #70229
    Darren
    • Topics: 73
    • Replies: 923
    • Posts: 996

    Hi Louis,

    You need to offset the entire signal:

    Alternatively, you can change the Date Range of the watchlist to only load the data to last Friday and not use the offset.

    Capture

    #70231
    Louis
    • Topics: 40
    • Replies: 69
    • Posts: 109

    Hi Darren. Thank you. This works perfectly when I use the 13-bar range. I don’t know how to apply this when the range is All Time.

    The attached chart shows weekly bars and a watchlist for the ticker ULTA. The current bar is the week in progress and printing an all-time closing higher. I can identify this using the script:

    I now want to know if the previous bar printed an all-time closing high, which it did. Offsetting the entire signal does not seem to work:

    I have the watchlist Date Range set to everything, so I am not sure how to ask if the previous week’s bar printed an all-time closing high.
    Thank you.

    Attachments:
    #70259
    Darren
    • Topics: 73
    • Replies: 923
    • Posts: 996

    Hi Louis,

    The Range = All-Time high is just a single price, so there’s no history. To get the all-time high as at a point in time (ie the previous week) use Range = All History:

    Here’s the difference between the two plotted in a Show View:

    Capture

    #70261
    Louis
    • Topics: 40
    • Replies: 69
    • Posts: 109

    Thanks Darren! Everything is working perfectly now. I appreciate your help very much.

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

Pin It on Pinterest