TTR's RSI
Hi Josh, I am attaching the following files test.Rdata (with data.xmin, the xts object) replic.r replic.output.txt (output when I source replic.r) Thanks Haky
On Tue, Apr 28, 2009 at 5:49 PM, Josh Ulrich <josh.m.ulrich at gmail.com> wrote:
Hi Haky, Could you provide more information? ?I cannot replicate your results.
Lines <- " Open High Low Close Volume
\"2008-03-16 17:00:00\" ?119 ?120 119 ? 119 ? 1305 \"2008-03-16 18:00:00\" ?119 ?120 119 ? 120 ? 3237 \"2008-03-16 19:00:00\" ?120 ?120 120 ? 120 ? 2813 \"2008-03-16 20:00:00\" ?120 ?120 120 ? 120 ? 2857 \"2008-03-16 21:00:00\" ?120 ?120 120 ? 120 ? 4561 \"2008-03-16 22:00:00\" ?120 ?120 120 ? 120 ? 1988 \"2008-03-16 23:00:00\" ?120 ?120 120 ? 120 ? ?805 \"2008-03-17 00:00:00\" ?120 ?120 120 ? 120 ? 1177 \"2008-03-17 01:00:00\" ?120 ?120 120 ? 120 ? 1245 \"2008-03-17 02:00:00\" ?120 ?120 120 ? 120 ? 1263 \"2008-03-17 03:00:00\" ?120 ?120 120 ? 120 ? 5565 \"2008-03-17 04:00:00\" ?120 ?120 120 ? 120 ? 4081 \"2008-03-17 05:00:00\" ?120 ?120 120 ? 120 ? 4462 \"2008-03-17 06:00:00\" ?120 ?120 120 ? 120 ?12409 \"2008-03-17 07:00:00\" ?120 ?120 119 ? 119 ?34083 \"2008-03-17 08:00:00\" ?119 ?120 119 ? 120 ?34742 \"2008-03-17 09:00:00\" ?120 ?120 120 ? 120 ?29412 \"2008-03-17 10:00:00\" ?120 ?120 120 ? 120 ?40087 \"2008-03-17 11:00:00\" ?120 ?120 120 ? 120 ?21834 \"2008-03-17 12:00:00\" ?120 ?120 120 ? 120 ?26442 \"2008-03-17 13:00:00\" ?120 ?120 120 ? 120 ?36671 \"2008-03-17 14:00:00\" ?120 ?120 120 ? 120 ?20468 \"2008-03-17 15:00:00\" ?120 ?120 120 ? 120 ? 8802"
data.60min <- read.table(textConnection(Lines)) dim(data.60min)
[1] 23 ?5
#class(data.xmin) ?# I don't know what the 'data.xmin' object is... class(data.60min)
[1] "data.frame"
length(RSI(data.60min[,"Close"]))
[1] 23
length(RSI(as.xts(data.60min)[,"Close"]))
[1] 23
sessionInfo()
R version 2.9.0 (2009-04-17) i386-unknown-freebsd7.1 locale: C attached base packages: [1] stats ? ? graphics ?grDevices utils ? ? datasets ?methods ? base other attached packages: [1] TTR_0.2-1 xts_0.6-4 zoo_1.5-5 loaded via a namespace (and not attached): [1] grid_2.9.0 ? ? ?lattice_0.17-22 Best, Josh -- http://quantemplation.blogspot.com http://www.fosstrading.com On Tue, Apr 28, 2009 at 5:29 PM, Hae Kyung Im <haky.im at gmail.com> wrote:
Hi, for some reason when I calculate RSI on a xts object of length n, I get a result of length n+1 as in the following example:
dim(data.60min)
[1] 23 ?5
class(data.xmin)
[1] "xts" "zoo"
length(RSI(data.60min[,"Close"]))
[1] 24 If I plug in a vector of length 23, RSI gives me a vector of length 23.
length(RSI(runif(23)))
[1] 23 am I missing something here? Thanks Haky -------------------------------------------- Here is the data for your reference:
data.60min
? ? ? ? ? ? ? ? ? ?Open High Low Close Volume 2008-03-16 17:00:00 ?119 ?120 119 ? 119 ? 1305 2008-03-16 18:00:00 ?119 ?120 119 ? 120 ? 3237 2008-03-16 19:00:00 ?120 ?120 120 ? 120 ? 2813 2008-03-16 20:00:00 ?120 ?120 120 ? 120 ? 2857 2008-03-16 21:00:00 ?120 ?120 120 ? 120 ? 4561 2008-03-16 22:00:00 ?120 ?120 120 ? 120 ? 1988 2008-03-16 23:00:00 ?120 ?120 120 ? 120 ? ?805 2008-03-17 00:00:00 ?120 ?120 120 ? 120 ? 1177 2008-03-17 01:00:00 ?120 ?120 120 ? 120 ? 1245 2008-03-17 02:00:00 ?120 ?120 120 ? 120 ? 1263 2008-03-17 03:00:00 ?120 ?120 120 ? 120 ? 5565 2008-03-17 04:00:00 ?120 ?120 120 ? 120 ? 4081 2008-03-17 05:00:00 ?120 ?120 120 ? 120 ? 4462 2008-03-17 06:00:00 ?120 ?120 120 ? 120 ?12409 2008-03-17 07:00:00 ?120 ?120 119 ? 119 ?34083 2008-03-17 08:00:00 ?119 ?120 119 ? 120 ?34742 2008-03-17 09:00:00 ?120 ?120 120 ? 120 ?29412 2008-03-17 10:00:00 ?120 ?120 120 ? 120 ?40087 2008-03-17 11:00:00 ?120 ?120 120 ? 120 ?21834 2008-03-17 12:00:00 ?120 ?120 120 ? 120 ?26442 2008-03-17 13:00:00 ?120 ?120 120 ? 120 ?36671 2008-03-17 14:00:00 ?120 ?120 120 ? 120 ?20468 2008-03-17 15:00:00 ?120 ?120 120 ? 120 ? 8802
_______________________________________________ R-SIG-Finance at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. -- If you want to post, subscribe first.