Find Highest and Lowest within a set of bars

Within my afl code, I have ‘startBar’ and ‘endBar’ that denotes the start and end bar number of a set of bars. I am trying to find the Highest price and Lowest price within this set of bars.
With the code snippet given below, I am able to find the correct values as required. Is this the right way or is there any better way to do it?

bi = BarIndex();
startBarArr = bi == startBar;
endBarArr = bi == endBar;
rangeHigh = LastValue( ValueWhen( endBarArr, HighestSince( startBarArr, High ) ) );
rangeLow = LastValue( ValueWhen( endBarArr, LowestSince( startBarArr, Low ) ) );

The very same question is already answered. SEARCH before posting new topics.