Plot Open--High--Low--Close Bar Chart

Plots open--high--low--close bar chart of a (financial) time series.

hplot, ts
plotOHLC(x, xlim = NULL, ylim = NULL, xlab = "Time", ylab, col = par("col"),
         bg = par("bg"), axes = TRUE, frame.plot = axes, ann = par("ann"),
         main = NULL, date = c("calendar", "julian"), format = "%Y-%m-%d", ...)
a multivariate time series object of class "mts".
xlim, ylim
xlab, ylab
col, bg
axes, frame.plot
ann, main
graphical arguments, see plot, plot.default and par.
a string indicating the type of x axis annotation. Default is calendar dates.
a string indicating the format of the x axis annotation if date == "calendar". For details see format.POSIXct.
further graphical arguments passed to plot.window, title, axis, and

Within an open--high--low--close bar chart, each bar represents price information for the time interval between the open and the close price. The left tick for each bar indicates the open price for the time interval. The right tick indicates the closing price for the time interval. The vertical length of the bar represents the price range for the time interval.

See Also

plot.default, format.POSIXct, get.hist.quote

  • plotOHLC
# Plot OHLC bar chart for the last `nDays' days of the instrument `instrument'

nDays <- 50
instrument <- "^spc"

start <- strftime(as.POSIXlt(Sys.time() - nDays*24*3600), format="%Y-%m-%d") 
end <- strftime(as.POSIXlt(Sys.time()), format = "%Y-%m-%d") 
x <- get.hist.quote(instrument = instrument, start = start, end = end)

plotOHLC(x, ylab = "price", main = instrument)
Documentation reproduced from package tseries, version 0.8-3, License: GPL (see file COPYING), except for ./src/muin2ser.f and ./misc which are free for non-commercial purposes. See file README for details.

Community examples

Looks like there are no examples yet.