If a potentiometer is turned clockwise and then counterclockwise, is there any way of finding the highest degrees it turned?
Implementation depends on the language, but in general you just save the maximum value.
Do a comparison of new values against the old maximum value (start w/ a maximum of zero), if the new value is greater, then it becomes the maximum value.
Here’s a generic LabVIEW example (replace the dice with the analog input).