Charting indicators
The various indicators can be added to the price chart—or charted
seperately—with the indicator-function. The
indicator-function will attach itself to the last
chart.
If you have already called the chart-function, and want
to plot the indicator seperately you will have to clear the existing
chart—this is done by calling talib::chart() without any
arguments. The indicator can now be re-charted using the
indicator-function.
{
## clear the chart
## by calling talib::chart()
## without any arguments
talib::chart()
## rechart the indicator
## directly
talib::indicator(
FUN = talib::MACD,
data = talib::BTC
)
}
#> Warning: Ignoring 33 observationsNotice here that you have to pass a data argument via
... which gets passed downstream to MACD.
Modifying charts
The charts can be globally modified via options use
?talib::chart to see the full range of modifications
available for the charting. Below is an example on how to modify the
color scheme of the charts.
## modify options
## to create charts in
## light and color-deficiency mode
options(
talib.chart.dark = FALSE,
talib.chart.deficieny = TRUE
)
{
## price chart
## with defaults
talib::chart(
talib::SPY
)
## add RSI indicator
talib::indicator(
FUN = talib::RSI
)
## add Bollinger Bands
talib::indicator(
FUN = talib::BBANDS
)
}Modifying x-axis labels
Internally chart() and indicator() are
working on the range of the the data—ie. 1:nrow(data)—to
easy the process of subsetting and for the efficiency. The x-axis can be
labelled with dates from the data via the idx-argument.
