I solved the problem using linear regression:
The points below the blue line receives zero, and the value points above the blue line are subtracted by the value of the same point in the linear regression. Something like this:
if data[x] < linearRegression[x]
data[x] = 0
else
data[x] = data[x] - linearRegression[x]
end
Note: in this case I don't care about the value itself, I just need to see where the peak occurs.