Learn R Programming

quantmod (version 0.3-3)

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"), 
           subset = NULL,
           show.grid = TRUE, 
           name = NULL,
           time.scale = NULL,
           TA = c(addVo()),
           line.type = "l",
           bar.type = "ohlc",
           xlab = "time", ylab = "price", theme = chartTheme("black"),
           major.ticks='auto', minor.ticks=TRUE,
           up.col,dn.col,color.vol = TRUE, multi.col = FALSE,
           ...)

Arguments

x
an OHLC object - see details
type
style of chart to draw
subset
currently unused
show.grid
display price grid lines?
name
name of chart
time.scale
what is the timescale? automatically deduced
TA
a vector of technical indicators and params
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
a chart.theme object
major.ticks
where should major ticks be drawn
minor.ticks
should minor ticks be draw?
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.

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

TA allows for the inclusion of a variety of chart overlays and tecnical indicators. A full list is available from addTA. The default TA argument is addVo() - which adds volume, if available, to the chart being drawn.

theme requires an object of class chart.theme, created by a call to chartTheme. This function can be used to modify the look of the resulting chart. See chart.theme for details.

line.type and bar.type allow further fine tuning of chart styles to user tastes.

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, addTA, setTA, chartTheme

Examples

Run this code
getSymbols("YHOO")
chartSeries(YHOO)
chartSeries(YHOO,theme=chartTheme('white'))
chartSeries(YHOO,TA=NULL)   #no volume
chartSeries(YHOO,TA=c(addVo(),addBBands()))  #add volume and Bollinger Bands from TTR

addMACD()   #  add MACD indicator to current chart

setTA()
chartSeries(YHOO)   #draws chart again, this time will all indicators present

Run the code above in your browser using DataLab