Thanks for posting this again. I updated the title of the question to correctly describe this request.
The solution requires that you have at least 360 days of data applied to the chart. This means the lower limit to getting this to work is the 1 hour time frame with 360 days of historical data on the chart.
def highOfYear = high(period = AggregationPeriod.YEAR);
def lowOfYear = low(period = AggregationPeriod.YEAR);
def lastYear = GetLastYear() == GetYear();
plot currentYearHigh = if lastYear then highOfYear else Double.NaN;
plot currentYearLow = if lastYear then lowOfYear else Double.NaN;
rec trackYearHigh = if lastYear <> lastYear[1] then highOfYear[1] else trackYearHigh[1];
rec trackYearLow = if lastYear <> lastYear[1] then lowOfYear[1] else trackYearLow[1];
plot previousYearHigh = if lastYear then trackYearHigh else Double.NaN;
plot previousYearLow = if lastYear then trackYearLow else Double.NaN;