chart | R Documentation |
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.
chart(
ticker,
main = kline(),
sub = list(),
indicator = list(),
event_data = NULL,
options = list()
)
ticker |
An object with Open, High, Low, Close and Volume columns that
can be coerced to a |
main |
A |
sub |
An optional list of |
indicator |
An optional list of |
event_data |
An optional data.frame with event line(s) to be added
to the |
options |
An optional list of |
dark
A <logical>-value of length 1. TRUE by default.
Sets the overall theme of the chart()
slider
A <logical>-value of length 1. FALSE by default.
If TRUE, a plotly::rangeslider()
is added.
deficiency
A <logical>-value of length 1. FALSE by default.
If TRUE, all chart()
-elements are colorblind friendly
size
A <numeric>-value of length 1. The relative size of the
main chart. 0.6 by default. Must be between 0 and 1, non-inclusive.
scale
A <numeric>-value of length 1. 1 by default. Scales
all fonts on the chart.
width
A <numeric>-value of length 1. 0.9 by default. Sets
the width of all line elements on the chart.
static
A <logical>-value of length 1. FALSE by default. If FALSE
the chart can be edited, annotated and explored interactively.
palette
A <character>-vector of length 1. "hawaii" by default. See hcl.pals()
for
all possible color palettes.
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()
.
A plotly::plot_ly()
object.
Sample Output
Serkan Korkmaz
Other chart indicators:
add_event()
,
alma()
,
bollinger_bands()
,
dema()
,
donchian_channel()
,
ema()
,
evwma()
,
fgi()
,
hma()
,
lsr()
,
macd()
,
rsi()
,
sma()
,
smi()
,
volume()
,
vwap()
,
wma()
,
zlema()
Other price charts:
kline()
,
ohlc()
,
pline()
# 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;
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.