Optuma Forums › Optuma Scripting › Was the previous bar a 13-week closing high?
Tagged: Watchlist, highesthigh, new high, New Low, Showbar, OFFSET, highestlow
- This topic has 4 replies, 2 voices, and was last updated 1 week ago by
Louis.
-
AuthorPosts
-
January 25, 2023 at 5:32 am #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:
123CLOSE() >= 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”:
123CLOSE()[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.
January 25, 2023 at 9:51 am #70229Darren
- Topics: 73
- Replies: 923
- Posts: 996
Hi Louis,
You need to offset the entire signal:
1234Sig1=(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.
January 26, 2023 at 3:00 am #70231Louis
- 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:
1234Sig1 = (CLOSE() >= HIGHESTHIGH(CLOSE(), RANGE=All Time)) ;Sig1I 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:
1234Sig1 = (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.Attachments:
You must be logged in to access attached files.
January 30, 2023 at 12:30 pm #70259Darren
- 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:
1234Sig1=(CLOSE() >= HIGHESTHIGH(CLOSE(), RANGE=All History));Sig1[1]Here’s the difference between the two plotted in a Show View:
January 30, 2023 at 1:34 pm #70261 -
AuthorPosts
- You must be logged in to reply to this topic.