LowestLow Date

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.

lowest low date

highest high

lowest low

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

Hi,

here is my updated watch list.

The one in my last post used data only available on my computer.

My final updated watch list, with data from the Optuma databases

Optuma-Watch-List-1.owb (26.9 KB)

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

//Go Back 52 Weeks to trigger signal start
start = BARDATE() == LAST(BARDATE()) - (52*7);
//Find where signal matches the Lowest Low Value
sig = Low() == LOWESTSINCE(start);
//Remove Non Zero results showing most recent result as latest value
date = BarDate(nonzero(sig));
date

This should return the results you’re expecting to see in the WL column.

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

Optuma-Watch-List-2.owb (27.5 KB)

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.

Hi Matthew,

have you any idea how to solve the issue of the lowest low date script as outlined above?

Thanks

Thomas

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:

lastyear = DATATOLOAD(RANGE=Weeks, AMOUNT=52) ;
a = LOWESTLOW(lastyear, RANGE=All Time);
bardate(a == low())

Here’s a variation to get the date of the 52 week lowest close, rather than the lowest low:

V0 = 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:

Capture

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:

Capture

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:

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

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

Capture

Hi,

For those interested in this topic here is a summary of the scripts:

52-Week Highest High

HIGHESTHIGH(BACKTYPE=Weeks, BARS=52, INCBAR=True)

52-Week Highest Close Date

// Define Lookback eg 252 Trading Days for a Year 
Line1 = (BARINDEX() == LAST(BARINDEX() - 252)) ; 
Line2 = CLOSE() ; 

// Find when the Close Matches the Highest Close Value over that Period 
Line3 = Line2 == HIGHESTSINCE(Line2, Line1); 

// Remove Zero Results Showing Most Recent Result as Latest vValue, and Display as Bardate 
Line4 = BarDate(NonZero(Line3)) ; 
Line4

52-Week Highest High Date

// Define Lookback eg 252 Trading Days for a Year 
Line1 = (BARINDEX() == LAST(BARINDEX() - 252)) ; 

// Find when the High Matches the Highest High Value over that Period 
Line2 = HIGH() == HIGHESTSINCE(Line1) ; 

// Remove Zero Results Showing Most Recent Result as Latest Value, and Display as Bardate 
Line3 = BarDate(NonZero(Line2)) ; 
Line3

52-Week Lowest Low

LOWESTLOW(BACKTYPE=Weeks, BARS=52, INCBAR=True)

52-Week Lowest Close Date

// Define Lookback eg 252 Trading Days for a Year 
Line1 = (BARINDEX() == LAST(BARINDEX() - 252)) ; 
Line2 = CLOSE() ; 

// Find when the close matches the lowest close value over that period 
Line3 = Line2 == LOWESTSINCE(Line2, Line1); 

// Remove Zero Results Showing Most Recent Result as Latest Value, and Display as Bardate 
Line4 = BarDate(NonZero(Line3)) ; 
Line4

52-Week Lowest Low Date

// Define Lookback eg 252 Trading Days for a Year 
Line1 = (BARINDEX() == LAST(BARINDEX() - 252)) ; 

// Find when the Low Matches the Lowest Low Value over that Period 
Line2 = LOW() == LOWESTSINCE(Line1) ; 

// Remove Zero Results Showing Most Recent Result as Latest Value, and Display as Bardate 
Line3 = BarDate(NonZero(Line2)) ; 
Line3

Thank you Darren for your great support.

Best wishes,
Thomas

Hii Sir,

Can we find first and last dates of 52 week lows using this script.

Regards,
Deepak