[R-SIG-Finance] Crosses above, crosses below

Joshua Ulrich josh.m.ulrich at gmail.com
Sat Sep 28 02:33:34 CEST 2013


On Fri, Sep 27, 2013 at 7:17 PM, Mark Knecht <markknecht at gmail.com> wrote:
> Only slightly financial. Is there a function somewhere that implements
> a real crossing check, as in MA1 crosses above MA2 and not just
> MA1>MA2?. TTR seemed a likely candidate but I haven't found it there.
>
Yes, diff().

library(quantmod)
x <- Cl(getSymbols("SPY", auto.assign=FALSE))
y <- EMA(x,10) > EMA(x,20)
z <- merge(y, diff(y))

> I alsa tried sos's findFn for searching, as well as stackoverflow but
> it seems too general a question.
>
> Thanks,
> Mark
>

--
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com



More information about the R-SIG-Finance mailing list