We can find how many bars ago the high or low was but we can't use a dynamic index with GetYYYYMMDD()[offset]. It requires a constant. GetValue() is a workaround for this but GetValue() assumes we're getting a number, such as high or low, and it loses the date formatting. The result for the current date, when displayed in a label, ends up being
20,210,817
. The code below will give you the correct date with wrong formatting. I can't think of a solution for getting the correct date with the correct formatting. Another option, if you don't like this formatting, would be to display the offset itself, i.e. the number 12 would mean 12 weeks ago.
Ruby:
AddLabel(
yes,
GetValue(GetYYYYMMDD(), GetMaxValueOffset(high(period=AggregationPeriod.WEEK), 52), 52),
Color.LIGHT_GRAY
);