Since just local extremum does not suit, you need to add an exceeding the threshold for rejecting small peaks and artifacts. The threshold can be calculated as samples multiplied by a certain constant corresponding to a confidence interval for mathematical expectation.
In practice, this constant is accepted equal to 2.5
upd
taking into account the additional conditions of the task of the PIC maximum should be considered at the same time From the "top" (the starting point or the first value higher than q ) to "bottom" (the first value below -q ). Threshold q . Put top = 0 . Find the coordinate bottom the first point of the segment [top, n-1] . -q . If there is no such point, go to paragraph 7. Find the maximum coordinate on the segment [top, Bottom-1] . If the value of the maximum is greater than the q Сode>, write it in an array of peaks. Find the coordinate top the first point of the segment [Bottom+1, N-1] with the value of the larger q . If there is no such point, go to p. 7. go to paragraph 3. use the peak array.