Find peaks and falls in data array

I have a series of data from which I have to find the values / moments in which the ascending sequence goes goes in descending order to determine the peak and vice versa. The data is changed by a sine law, but the peaks and falls have different absolute values. Currently, I place the data in a fixed length FIFO array (with buffer-array node) and found the maximum and minimum values with change node, but in this way I find only a single peak or a fall (the highest or the lowest), while there are more than one in the array.
Please help me to solve this problem.

2 Likes

Ugh! If the code found by @ukmoose works for you, don't read any more. If you have discovered any of the serious problems with it, you might feel better knowing that this is one of the oldest and most difficult problems in applied mathematics. It is hard to suggest improvements without knowing something about the source of your data and the use you want to make of it. Good luck, and let us know if you need help.

Thanks for both comments!
I was able to modify the example so I can find the peaks in both directions.