getPeakTrough function

Identify peak or trough on curve