The idea is simple: if the High of the current bar is lower than that of the previous, less than the High n bars ago and the indicator value of the previous bar, then the indicator line is equal to the High. The opposite is for the Lows.
The movement nature of the indicator line resembles the MA, but filters the noises better.