At first, this question can sound really stupid, but it is not in fundamental. Maybe, it can seem like unresolvable exactly by any algorithm, but I pretend to say it is.
You'll usually start with a moving average -- that is, averaging the N most recent points, where the degree of smoothing is roughly proportional to N (i.e., as yoy average more points, your result gets smoother).
Then you can take the differences between each averaged point and the next. Where the difference changes sign, you have a minimum or maximum (where it goes from positive to negative, you have a maximum, from negative to positive, a minimum).