Re: [R] intraday OHLC plot

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Sat, 22 Mar 2008 08:07:13 -0400

Try this:

Lines <- '"Date (GMT)"	"Open"	"High"	"Low"	"Last"
17-03-2008 00:00:00	1,5764	1,5766	1,5747	1,5750
17-03-2008 00:05:00	1,5749	1,5750	1,5741	1,5744
17-03-2008 00:10:00	1,5745	1,5762	1,5741	1,5749'
DF <- read.delim2(textConnection(Lines))

library(quantmod)
z <- read.zoo(textConnection(Lines), # replace with "myfile.dat"

    header = TRUE, sep = "\t", dec = ",",
    format = "%d-%m-%Y %H:%M:%S", tz = "")
q <- as.quantmod.OHLC(z, col.names = c("Open", "High", "Low", "Close"))
chartSeries(q)

Look at the zoo, quantmod and xts packages for more info.

On Sat, Mar 22, 2008 at 6:19 AM, Thomas Steiner <finbref.2006_at_gmail.com> wrote:
> I want to create a open/high/low/last plot of intraday data.
> I try to use the function plotOHLC from the tsteries package. I create
> my own multiple time series and then try to plot it.
>
> raw Data Format (file eurusd2.csv):
> "Date (GMT)" "Open" "High" "Low" "Last"
> 17-03-2008 00:00:00 1,5764 1,5766 1,5747 1,5750
> 17-03-2008 00:05:00 1,5749 1,5750 1,5741 1,5744
> 17-03-2008 00:10:00 1,5745 1,5762 1,5741 1,5749
>
> > library("tseries")
> > raw=read.delim2("eurusd2.csv")
> > date.d=strptime(raw$Date..GMT,"%d-%m-%Y %H:%M:%S")
> > x=ts(data=c(raw$Open,raw$High,raw$Low,raw$Last),c="mts")
> > plotOHLC(x)
> Fehler in if ((!is.mts(x)) || (colnames(x)[1] != "Open") ||
> (colnames(x)[2] != :
> Fehlender Wert, wo TRUE/FALSE nötig ist
> >
>
> so there is a value missing where it expected a T/F...
>
> In Details of the help on the function plotOHLC it says:
> The time scale of x must be in Julian dates (days since the origin).
>
> Perhaps anyone can provide help here?
> Thanks,
> Thomas
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sat 22 Mar 2008 - 12:12:13 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 23 Mar 2008 - 15:30:24 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive