Optuma Forums › Optuma Scripting › LowestLow Date
Tagged: lowestlow date, highesthigh
- This topic has 11 replies, 4 voices, and was last updated 7 months ago by
Deepak.
-
AuthorPosts
-
March 12, 2020 at 11:03 pm #57319
Thomas
- Topics: 140
- Replies: 189
- Posts: 329
Hi,
I have created a scripts to show the date of the highest 52-week high and a script to show the lowest 52-week low.
The shown dates in the watch list for the highest 52-week highs seem to be correct but the dates for the lowest 52-week lows are mostly wrong.
Here are the scripts:
Date of the highest 52-week high
Var1 = HIGH() == HIGHESTHIGH(BACKTYPE=Weeks, BARS=52, INCBAR=True);
BARDATE(Var1)Date of the lowest 52-week low
Var1 = LOW() == LOWESTLOW(BACKTYPE=Weeks, BARS=52, INCBAR=True);
BARDATE(Var1)I have also uploaded my watch list.
Interestingly the values of the highest 52-week highs and the lowest 52-week lows are correct but not the dates.
My script for the highest 52-week high
HIGHESTHIGH(High(), BACKTYPE=Weeks, BARS=52, INCBAR=True)
My script for the lowest 52-week low
LOWESTLOW(Low(), BACKTYPE=Weeks, BARS=52, INCBAR=True)
Inform me please what I have made wrong.
Thanks
Thomas
March 13, 2020 at 12:49 am #57327Thomas
- Topics: 140
- Replies: 189
- Posts: 329
Hi,
here is my updated watch list.
The one in my last post used data only available on my computer.
March 13, 2020 at 1:40 am #57333Thomas
- Topics: 140
- Replies: 189
- Posts: 329
My final updated watch list, with data from the Optuma databases
March 13, 2020 at 11:12 am #57340Matthew
- Topics: 5
- Replies: 670
- Posts: 675
Hi Thomas,
The results for the low you are seeing are from the first match found within the 52 week range. The result you are after is from the most recent bar, the way to do this in a Watchlist is to use a script like this (i’ve included notes on what each step does):
123456789//Go Back 52 Weeks to trigger signal startstart = BARDATE() == LAST(BARDATE()) - (52*7);//Find where signal matches the Lowest Low Valuesig = Low() == LOWESTSINCE(start);//Remove Non Zero results showing most recent result as latest valuedate = BarDate(nonzero(sig));dateThis should return the results you’re expecting to see in the WL column.
1 user thanked author for this post.
March 13, 2020 at 4:41 pm #57349Thomas
- Topics: 140
- Replies: 189
- Posts: 329
Hi Matthew,
thank you for your script. In my watch list it works almost perfect but unfortunately not for Microsoft. The watch list shows the date 9/17/1987, that date is the first day data are available.
I have again attached my watch list.
Thanks
Thomas
March 13, 2020 at 5:22 pm #57353Thomas
- Topics: 140
- Replies: 189
- Posts: 329
Hi Matthew,
perhaps I have figured out the issue in the script.
The lowest low was 114.59 (see watch list). That low was on Friday, March 15, 2019.
If you multiply 52 * 7 you get 364, if you subtract 364 calendar days from March 12, 2020 (last bar date) you get Thursday, March 14, 2019.
Perhaps since the lowest low date and the start of the script (start = BARDATE() == LAST(BARDATE()) – (52*7)) are so close together the issue occurs.
March 17, 2020 at 3:49 am #57383Thomas
- Topics: 140
- Replies: 189
- Posts: 329
Hi Matthew,
have you any idea how to solve the issue of the lowest low date script as outlined above?
Thanks
Thomas
March 17, 2020 at 12:56 pm #57402Matthew
- Topics: 5
- Replies: 670
- Posts: 675
Hi Thomas,
We think it’s the LowestSince() function that’s causing this outlier issue, we’re looking into it further. For now the following adjusted script seems to be working without producing the outliers:
12345lastyear = DATATOLOAD(RANGE=Weeks, AMOUNT=52) ;a = LOWESTLOW(lastyear, RANGE=All Time);bardate(a == low())1 user thanked author for this post.
June 16, 2021 at 7:21 pm #64979Darren
- Topics: 74
- Replies: 967
- Posts: 1,041
Here’s a variation to get the date of the 52 week lowest close, rather than the lowest low:
12345678V0 = CLOSE() ;V1 = DATATOLOAD(V0,RANGE=Weeks, AMOUNT=52);V2 = 0;V3 = MAX(V1,V2);V4 = LOWESTLOW(V3, RANGE=All Time);BARDATE(V0 ==V4)For highest close change V4 from LOWESTLOW to HIGHESTHIGH. This example shows the highest 52 week close date for AMGN was July 20th 2020:
1 user thanked author for this post.
October 6, 2022 at 9:09 pm #69477Darren
- Topics: 74
- Replies: 967
- Posts: 1,041
Hi Thomas,
In our fundamental data we now have have dates for high and low prices over the week, month, quarter, 6 months, year, and all-time. These can be added as a watchlist column from the Fundamental Field list without having to create a formula:
However, this will only work for equities and ETFs as fundamental data isn’t available for indices, forex, cryptos, etc. I’ve come up with an alternative using BARINDEX() instead of BARDATE() to avoid weekends and holidays:
52 week low date:
12345678//Define lookback eg 252 trading days for a year;Start = (BARINDEX() == LAST(BARINDEX() - 252));//Find when the low matches the lowest low value over that period;Sig = LOW() == LOWESTSINCE(Start);//Remove Zero results showing most recent result as latest value, and display as bardate;BarDate(NonZero(Sig))52 week lowest close date:
123456789//Define lookback eg 252 trading days for a year;Start = (BARINDEX() == LAST(BARINDEX() - 252));C1 = CLOSE();//Find when the close matches the lowest close value over that period;Sig = C1 == LOWESTSINCE(C1,Start);//Remove Zero results showing most recent result as latest value, and display as bardate;BarDate(NonZero(Sig))In this example, the 52 week low for Home Depot was on June 22nd ($264.51), but the lowest close ($266.58) occurred on September 26th:
1 user thanked author for this post.
October 8, 2022 at 4:10 am #69493Thomas
- Topics: 140
- Replies: 189
- Posts: 329
Hi,
For those interested in this topic here is a summary of the scripts:
52-Week Highest High
123HIGHESTHIGH(BACKTYPE=Weeks, BARS=52, INCBAR=True)52-Week Highest Close Date
123456789101112// Define Lookback eg 252 Trading Days for a YearLine1 = (BARINDEX() == LAST(BARINDEX() - 252)) ;Line2 = CLOSE() ;// Find when the Close Matches the Highest Close Value over that PeriodLine3 = Line2 == HIGHESTSINCE(Line2, Line1);// Remove Zero Results Showing Most Recent Result as Latest vValue, and Display as BardateLine4 = BarDate(NonZero(Line3)) ;Line452-Week Highest High Date
1234567891011// Define Lookback eg 252 Trading Days for a YearLine1 = (BARINDEX() == LAST(BARINDEX() - 252)) ;// Find when the High Matches the Highest High Value over that PeriodLine2 = HIGH() == HIGHESTSINCE(Line1) ;// Remove Zero Results Showing Most Recent Result as Latest Value, and Display as BardateLine3 = BarDate(NonZero(Line2)) ;Line352-Week Lowest Low
123LOWESTLOW(BACKTYPE=Weeks, BARS=52, INCBAR=True)52-Week Lowest Close Date
123456789101112// Define Lookback eg 252 Trading Days for a YearLine1 = (BARINDEX() == LAST(BARINDEX() - 252)) ;Line2 = CLOSE() ;// Find when the close matches the lowest close value over that periodLine3 = Line2 == LOWESTSINCE(Line2, Line1);// Remove Zero Results Showing Most Recent Result as Latest Value, and Display as BardateLine4 = BarDate(NonZero(Line3)) ;Line452-Week Lowest Low Date
1234567891011// Define Lookback eg 252 Trading Days for a YearLine1 = (BARINDEX() == LAST(BARINDEX() - 252)) ;// Find when the Low Matches the Lowest Low Value over that PeriodLine2 = LOW() == LOWESTSINCE(Line1) ;// Remove Zero Results Showing Most Recent Result as Latest Value, and Display as BardateLine3 = BarDate(NonZero(Line2)) ;Line3Thank you Darren for your great support.
Best wishes,
Thomas-
This reply was modified 8 months ago by
Thomas.
October 15, 2022 at 11:59 pm #69569Deepak
- Topics: 91
- Replies: 77
- Posts: 168
Hii Sir,
Can we find first and last dates of 52 week lows using this script.
Regards,
Deepak -
AuthorPosts
- You must be logged in to reply to this topic.