Plotting candlestick chart using rAmCharts

Share:

Description

amCandlestick computes a candlestick chart of the given value.

Usage

1
2
3
4
amCandlestick(data, xlab = "", ylab = "", horiz = FALSE,
  positiveColor = "#7f8da9", negativeColor = "#db4c3c", names = c("low",
  "open", "close", "high"), dataDateFormat = NULL,
  minPeriod = ifelse(!is.null(dataDateFormat), "DD", ""), ...)

Arguments

data

data.frame, dataframe with at least 5 columns: category, open (numeric), close (numeric), low (numeric), high (numeric). See data_candleStick1 and data_candleStick2.

xlab

character, label for x-axis.

ylab

character, label for y-axis.

horiz

logical, TRUE for an horizontal chart, FALSE for a vertical one

positiveColor

character, color for positive values (in hexadecimal).

negativeColor

character, color for negative values (in hexadecimal).

names

character, names for the tooltip. Default set to c("low", "open", "close", "high").

dataDateFormat

character, default set to NULL. Even if your chart parses dates, you can pass them as strings in your dataframe - all you need to do is to set data date format and the chart will parse dates to date objects. Check this page for available formats. Please note that two-digit years (YY) as well as literal month names (MMM) are NOT supported in this setting.

minPeriod

character, minPeriod Specifies the shortest period of your data. This should be set only if dataDateFormat is not NULL. Possible period values: fff - milliseconds, ss - seconds, mm - minutes, hh - hours, DD - days, MM - months, YYYY - years. It's also possible to supply a number for increments, i.e. '15mm' which will instruct the chart that your data is supplied in 15 minute increments.

...

see amOptions for more options.

See Also

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
data("data_candleStick2")
amCandlestick(data = data_candleStick2)


# Change colors
amCandlestick(data = data_candleStick2, positiveColor = "black", negativeColor = "green")

# Naming the axes
amCandlestick(data = data_candleStick2, xlab = "categories", ylab = "values")

# Rotate the labels for x axis
amCandlestick(data = data_candleStick2, labelRotation = 90)

# Change names
amCandlestick(data = data_candleStick2, names = c("min", "begin", "end", "max"))

# Horizontal chart :
amCandlestick(data = data_candleStick2, horiz = TRUE)

# Parse date              
amCandlestick(data = data_candleStick2, dataDateFormat = "YYYY-MM-DD")

# Datas over months
data_candleStick2$category <- c("2015-01-01", "2015-02-01", "2015-03-01",
                                "2015-04-01", "2015-05-01", "2015-06-01",
                                "2015-07-01", "2015-08-01", "2015-09-01",
                                "2015-10-01", "2015-11-01", "2015-12-01")

amCandlestick(data = data_candleStick2, dataDateFormat = "YYYY-MM-DD", minPeriod = "MM")

# Decimal precision
require(pipeR)
amCandlestick(data = data_candleStick2, horiz = TRUE) %>>%
  setProperties(precision = 2) 

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.