Algorithm to predict those highs and lows and provide optima