findPeaks

0th

Percentile

Find Peaks and Valleys In A Series

Functions to find the peaks (tops) and valleys (bottoms) of a given series.

Keywords
misc
Usage
findPeaks(x, thresh=0)
findValleys(x, thresh=0)
Arguments
x

a time series or vector

thresh

minimum peak/valley threshold

Value

A vector of integers corresponding to peaks/valleys.

As a peak[valley] is defined as the highest[lowest] value in a series, the function can only define it after a change in direction has occurred. This means that the function will always return the first period after the peak/valley of the data, so as not to accidentally induce a look-ahead bias.

Aliases
  • findPeaks
  • findValleys
  • peak
  • valley
Examples
# NOT RUN {
findPeaks(sin(1:10))

p <- findPeaks(sin(seq(1,10,.1)))
sin(seq(1,10,.1))[p]

plot(sin(seq(1,10,.1))[p])
plot(sin(seq(1,10,.1)),type='l')
points(p,sin(seq(1,10,.1))[p])
# }
Documentation reproduced from package quantmod, version 0.4-10, License: GPL-3

Community examples

joon kim/ppoint7@daum.net at Sep 11, 2017 quantmod v0.4-10

13505.74 13535.60 14218.32 15092.19 ​

joon kim/ppoint7@daum.net at Sep 11, 2017 quantmod v0.4-10

2001.22 137601.33 2008.12 8436.62 2011.20 22671.29 2014.82 47668.70 2024.43 560174.81 2033.93 11905.43 2040.07 236323.09 2055.84 95874.34 2085.84 21674.92 2127.23 53928.33 2171.11 409069.69 2210.30 12911.21 2216.99 351075.00 2224.32 48573.90 2237.03 13352.91 2244.25 49064.16 2282.74 22528.91 2313.06 12199.22 2352.57 17251.05 2400.03 25104.48 2431.49 42621.39 2439.84 3322.21 2537.42 26002.87 2552.51 7281.75 2582.37 3495.92 2620.67 123474.90 2671.30 3942.29 2679.19 391714.06 2688.33 23575.51 2691.83 5864.92 2698.04 25952.39 2776.69 53151.79 2781.66 2613.69 2988.13 121484.00 2995.82 24976.08 3007.29 5625.77 3021.09 54828.06 3027.59 53431.63 3113.65 2369.53 3172.45 199296.44 3185.61 121692.30 3200.66 2078.70 3211.25 5341.08 3238.78 6694.32 3257.28 242605.22 3269.76 70929.63 3277.04 11604.12 3282.44 1379.35 3302.70 45090.63 3358.66 9342.55 3415.26 306079.56 3423.66 9941.10 3428.39 4122.88 3433.65 10306.36 3446.11 177011.36 3455.26 4754.13 3463.79 37615.74 3498.05 5426.70 3517.90 185770.80 3550.91 11724.92 3601.56 23829.51 3615.68 87745.23 3645.34 1984836.63 3663.98 99781.80 3673.59 179498.77 3687.66 173492.16 3724.84 288383.44 3843.23 191137.39 3856.60 44718.14 3869.16 6086.47 3883.89 7371615.50 3899.76 388049.88 3921.57 448019.13 3936.39 8041.49 4060.66 19852.61 4114.35 55525.88 4126.07 17888.23 4164.43 14319.73 4240.22 17873.75 4336.68 993.51 4429.25 3003947.50 4445.41 113843.64 4467.69 200627.89 4491.94 249627.77 4499.37 13924.21 4510.42 92572.63 4531.36 358760.09 4619.37 135726.64 4658.12 239652.16 4676.73 38880.14 4777.21 1714363.88 4795.96 151450.41 4815.06 10241.23 4856.81 193146.41 4876.34 4886.05 4977.14 55523.74 4992.57 11914.58 5017.58 16269.05 5037.11 251654.08 5047.00 14115.25 5055.30 20913.38 5113.61 134276.53 5127.97 125549.46 5161.69 9882.71 5196.40 167594.75 5247.15 174141.13 5265.94 16992.53 5355.10 1954890.25 5371.44 89250.99 5381.99 14449.33 5392.87 143325.42 5471.13 78053.72 5504.42 27620.03 5521.66 11616.52 5536.47 78495.05 5552.53 20517.04 5565.93 32939.46 5686.93 10948.17 5783.81 153485.78 5805.70 13031.82 5821.46 44479.49 5829.58 16726.53 5896.22 9940.73 5934.82 11326.39 5973.08 689438.50 5991.27 40461.73 6011.23 85923.75 6039.25 133647.95 6053.70 195045.98 6170.70 663384.56 6184.24 119345.07 6342.29 938645.06 6356.86 64520.84 6379.22 30490.91 6492.68 77909.88 6512.13 984984.25 6536.34 255156.64 6550.40 46228.26 6563.26 29540.79 6576.74 5147.22 6602.41 226387.88 6618.36 32232.50 6702.62 98550.18 6747.60 30255.71 6768.78 44466.36 6828.59 663659.63 6846.68 22366.21 6866.53 14854.59 6889.52 463272.25 6905.83 4891.95 7008.70 11864.59 7034.06 409450.91 7098.06 62254.53 7108.67 82214.34 7128.01 107809.05 7201.59 257960.92 7229.47 748829.63 7289.10 3881252.50 7301.52 89843.24 7327.03 248587.31 7345.13 339046.69 7372.90 329305.38 7447.86 8614.88 7468.96 38306.20 7526.06 5118.93 7544.80 125534.23 7685.01 196647.70 7743.21 105544.43 7836.74 19374.59 7871.42 37044.62 8089.70 43965.97 8120.61 21445.57 8137.23 8057.74 8162.27 72592.77 8327.53 30832.46 8435.97 21311.34 8453.60 10856.73 8482.16 25936.96 8678.55 42160.32 8843.74 15948.99 8982.33 215363.98 9018.75 4127.08 9061.38 257225.72 9237.67 3174.59 9314.66 793878.19 9553.56 2195738.00 9579.23 112309.12 9712.98 105113.74 9954.24 15553.10 10074.02 202527.03 10101.44 66731.09 10228.64 39629.97 10256.12 299404.22 10392.23 33884.53 10494.64 119907.75 10939.76 24805.62 11074.04 15869.99 11101.37 4116.26 11127.95 5352.10 11508.04 745.26 11566.79 13367.70 11646.09 13452.01 12342.62 718137.19 12992.01 742.83 13505.74 592.73 13535.60 1061.69 14218.32 2560.94 15092.19 937.80 ​