Message-ID: <CAAmySGPUeGSti_ZKD3NjDq6KO-53yi+zqprd0Y-DdD1NumJjvQ@mail.gmail.com>
Date: 2012-02-10T03:00:58Z
From: R. Michael Weylandt
Subject: using findPeaks in designing railing-stops?
In-Reply-To: <CAPNjSFb6Rzh4t7qxZXD5naCW_AdS6HY0xfgx_9-fEmYkT0Xv=Q@mail.gmail.com>
It looks like you need to wrap coredata() because some funny
arithmetic is happening when the xts-ness is preserved.
e.g.
findPeaks(coredata(Ad(SPY)), 5)
But this is perhaps a less-than-desirable feature. I'll patch it and
send it to Josh.
Michael
On Thu, Feb 9, 2012 at 9:56 PM, Michael <comtech.usa at gmail.com> wrote:
> ?Hi all,
>
> I am having trouble using the function "findPeaks":
>
> tickers="SPY"
>
> data *<-* new.env()
>
> getSymbols(tickers, src = 'yahoo', from = '1970-01-01', env = data,
> auto.assign = T)
>
> p=findPeaks(data$SPY[, 6], 5)
>
> plot(data$SPY[, 6], type="l")
>
> points(p, data$SPY[, 6][p])
>
> My goal is to implement a trailing-stop on a buy-and-hold strategy using
> findPeaks...
>
> I wanted to detect whenever SPY falls 5 points from the local peak...
>
> The above example failed in finding the peaks (p == NULL).
>
> Am I missing anything here?
>
> Thanks a lot!
>
> ? ? ? ?[[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.