Assuming I guessed right about which edges in your graph are rising edges and which are falling edges, it looks like your solution has found the maximum, but it's output is delayed by two cycles from when the maximum occurred. You should expect this delay because the new value of y (your output variable) can only be determined once x(n-2), x(n-1), and x(n) have all been produced. Therefore, y only responds to the maximum in cycle n+1.
You could get the response in cycle n if you used only combinatorial logic to compare x(n) with the prior values, and didn't wait for a flip-flop to capture the result.
P.S.: You'll also have a problem if your sampling happens to produce two exactly equal samples (to the resolution of your ADC) straddling the maximum point.