Your code is wrong, but the idea is right. Shift the output series is equivalent to shifting the input series.

You can also use MaxVal instead of HH.