Learn R Programming

quantmod (version 0.2-5)

chartSeries: Create Financial Charts

Description

Charting tool to create standard financial charts given a time series like object. Serves as the base function for future technical analysis additions. Possible chart styles include candles, matches (1 pixel candles), bars, and lines. Chart may have white or black background.

Usage

chartSeries(x,
           type = c("auto", "candlesticks", "matchsticks", "bars","line"), 
           show.vol = TRUE, 
           show.grid = TRUE, 
           name = deparse(substitute(x)),
           time.scale = NULL,
           technicals = NULL,
           line.type = "l",
           bar.type = "ohlc",
           xlab = "time", ylab = "price", theme = "black",
           up.col,dn.col,color.vol = TRUE, multi.col = FALSE,
           ...)

barChart(x,name=deparse(substitute(x)),type='bars',...) candleChart(x,name=deparse(substitute(x)),type='candlesticks',...) lineChart(x,name=deparse(substitute(x)),type='line', color.vol=FALSE,...)

Arguments

x
an OHLC object - see details
type
style of chart to draw
show.vol
display volume on chart?
show.grid
display price grid lines?
name
name of chart
time.scale
what is the timescale? automatically deduced
technicals
a list of technical indicators and params (yet to be added)
line.type
type of line in line chart
bar.type
type of barchart - ohlc or hlc
xlab
derived time scale
ylab
y axis label
theme
'white' or 'black' background
up.col
up bar/candle color
dn.col
down bar/candle color
color.vol
color code volume?
multi.col
4 color candle pattern
...
additional parameters

Value

  • Returns a standard chart plus volume, if available, suitably scaled.

Details

Currently displays standard style OHLC charts familiar in financial applications, or line charts when not passes OHLC data. Works with objects having explicit time-series properties, at present limited to quantmod.OHLC data as returned by getSymbols.yahoo. In theory any zoo object conforming to OHLC conventions can be coerced to a quantmod.OHLC object, and thus charted.

Line charts are created with close data, or from single column time series.

Future versions will allow for additional charting functions to be called subsequently which will allow for additional information to be display on the chart, such as technical indicators/studies, as well as entry and exit points given a particular trade strategy.

line.type and bar.type allow further fine tuning of chart styles to user tastes, as do the addition of up.col and dn.col arguments.

multi.col implements a color coding scheme used in some charting applications, and follows the following rules:

  • grey
{ => Op[t] < Cl[t] and Op[t] < Cl[t-1]} white{ => Op[t] < Cl[t] and Op[t] > Cl[t-1]} red{ => Op[t] > Cl[t] and Op[t] < Cl[t-1]} black{ => Op[t] > Cl[t] and Op[t] > Cl[t-1]}

References

Josh Ulrich - TTR package and multi.col coding

See Also

getSymbols

Examples

Run this code
getSymbols("YHOO")
chartSeries(YHOO)

barChart(YHOO)
candleChart(YHOO)
matchChart(YHOO,theme="white")
lineChart(YHOO)

Run the code above in your browser using DataLab