The code you provided ends up computing the highest high from 5 sessions ago and the lowest low from 5 sessions ago.
A bit more detail to help you understand where you missed the mark:
You correctly used the higher time frame but you failed to include the second parameter in your use of the Highest() and Lowest() methods. Those two methods require the data point as the first parameter and the number of bars ago as the second parameter. Then you placed the index value of 5 at the end of those methods. Which merely shifts those methods to read data from 5 periods ago.
Here is what it looks like after correcting those issues:
input higherTimeFrame = AggregationPeriod.DAY;
input numberOfSessions = 5;
def periodHighest = Highest(high(period = higherTimeFrame)[1], numberOfSessions);
def periodLowest = Lowest(low(period = higherTimeFrame)[1], numberOfSessions);
plot targetHigh = periodHighest;
targetHigh.SetDefaultColor(Color.DARK_GREEN);
plot targetLow = periodLowest;
targetLow.SetDefaultColor(Color.DARK_RED);
I have included user inputs to adjust the higher time frame and number of previous session. Screenshot below shows how this looks on the chart.