There are limitations on the amount of historical data available to custom scans. For time frames less than 1 hour the scan engine only has 11-13 trading sessions to use. This scan will require at least 10 trading sessions to compute the key metrics. So this is right on the borderline of what is feasible for lower time frames. If you find it does not work on time frame below 1 hour, you will need to increase the time frame to 1 hour or higher.
This solution replaces the secondary aggregation with two recursive variables to track the weekly high and the previously weekly high:
def newWeek = GetWeek() <> GetWeek()[1];
rec weeklyHigh = if newWeek then high else if high > weeklyHigh[1] then high else weeklyHigh[1];
rec previousWeekHigh = if newWeek then weeklyHigh[1] else previousWeekHigh[1];
rec firstCrossAbove = if newWeek[-1] then 0 else if high > previousWeekHigh then 1 else firstCrossAbove[1];
plot crossingWeeklyHigh = firstCrossAbove and !firstCrossAbove[1];