Method used for peak detection, similar to MATLAB peakdet method
function(sample_x, sample_y, delta) Method for detecting peaks.
sample_x: float array, sample with indices.
sample_y: float array, sample with data.
delta: float, positive threshold value for detecting a peak.
Returns: tuple with found max/min peak indices.
fixed issue with example usage were it would crash in replay/large history buffer.
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in a publication is governed by House Rules.
Copy the following line and paste it in your script.