Skip to contents

[Experimental]

A high-level plotly::plot_ly()- and plotly::subplot()-wrapper function for building interactive financial charts using the affiliated chart-functions. The chart consists of a main chart, and an optional subchart. The main chart supports overlaying various trading indicators like sma and bollinger_bands.

Usage

chart(
  ticker,
  main = list(kline()),
  sub = list(),
  indicator = list(),
  event_data = NULL,
  options = list()
)

Arguments

ticker

An object with Open, High, Low, Close and Volume columns that can be coerced to a xts::xts()-object.

main

A plotly::plot_ly()-function. kline() by default.

sub

An optional list of plotly::plot_ly()-function(s).

indicator

An optional list of plotly::add_lines()-function(s).

event_data

An optional data.frame with event line(s) to be added to the chart(). See add_event() for more details.

options

An optional list of chart()-options. See details below.

Value

A plotly::plot_ly() object.

Sample Output

Details

Options

Charting Events

If event_data is passed, vertical eventlines with appropriate labels and coloring are added to the chart(). This function is rigid, as it will fail if event, label and index columns are not passed.

For more details please see add_event().

See also

Other chart indicators: add_event(), alma(), bollinger_bands(), dema(), ema(), evwma(), fgi(), hma(), lsr(), macd(), rsi(), sma(), volume(), vwap(), wma(), zlema()

Other price charts: kline(), ohlc(), pline()

Author

Serkan Korkmaz

Examples

# script start;

# 1) charting weekly
# BTC using candlesticks
# and indicators
cryptoQuotes::chart(
  ticker     = BTC,
  main       = cryptoQuotes::kline(),
  sub        = list(
    cryptoQuotes::volume(),
    cryptoQuotes::macd()
  ),
  indicator = list(
    cryptoQuotes::bollinger_bands(),
    cryptoQuotes::sma(),
    cryptoQuotes::alma()
  ),
  options = list(
    dark       = TRUE,
    deficiency = FALSE
  )
)
# script end;