I would like to do is what I thought to be a simple task: find the locations of peaks for a certain stock, and mark those peaks on a chart.
I was surprised by a lack of appropriate examples on the internet. For example, description of findPeaks function from quantmod package does not even explain what the second argument (thresh) represent. Could somebody please explain?
So, this is what I managed to do:
library(quantmod) APL <- getSymbols("AAPL", src = "yahoo", auto.assign = FALSE) aapl.price <-AAPL$AAPL.Close p <- findPeaks(aapl.price, 10) plot(aapl.price, type = 'l') points(aapl.price[p],index(aapl.price)[p], col = "red")
Obviously, there are different ways to define the peaks, but by any means the output here is not what one would want to see. Could somebody please provide any guidance?
Also, please let me know if this is best done using some other package