Was the previous bar a 13-week closing high?

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:

CLOSE() >= HIGHESTHIGH(BARS=13)

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”:

CLOSE()[1] >= HIGHESTHIGH(CLOSE(OFFSET=0), BARS=13)[1]

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.

Hi Louis,

You need to offset the entire signal:

Sig1=(CLOSE() >= HIGHESTHIGH(CLOSE(), BARS=13));
Sig1[1]

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

Capture

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:

Sig1 = (CLOSE() >= HIGHESTHIGH(CLOSE(), RANGE=All Time)) ; 
Sig1

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:

Sig1 = (CLOSE() >= HIGHESTHIGH(CLOSE(), RANGE=All Time)) ; 
Sig1[1]

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.

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:

Sig1=(CLOSE() >= HIGHESTHIGH(CLOSE(), RANGE=All History));
Sig1[1]

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

Capture

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