thanks for the reply. Yes that would make much more sense.

If we say Period is 100 and then Period2 is 50

The line MaxVal(Data, Period2) is that taking the max value over the first 50 periods of Data (1 to 50)?
Similarly for MaxVal(Data, Period) is taking the max value over the last 100 periods of Data (1 to 100)?
Lastly for MaxVal(Data + Period2, Period2) is taking the max value over periods 51 to 100?