Create an ichimoku object containing values for all components of the Ichimoku Kinko Hyo cloud chart. The object encapsulates a date-time index, OHLC pricing data, candle direction, the cloud lines Tenkan-sen, Kijun-sen, Senkou span A, Senkou span B and Chikou span, as well as values for the cloud top and cloud base.

ichimoku(x, ...)

# S3 method for ichimoku
ichimoku(x, ticker, periods = c(9L, 26L, 52L), keep.data, ...)

# S3 method for xts
ichimoku(x, ticker, periods = c(9L, 26L, 52L), keep.data, ...)

# S3 method for data.frame
ichimoku(x, ticker, periods = c(9L, 26L, 52L), keep.data, ...)

# S3 method for matrix
ichimoku(x, ticker, periods = c(9L, 26L, 52L), keep.data, ...)

# S3 method for default
ichimoku(x, ticker, periods = c(9L, 26L, 52L), keep.data, ...)

Arguments

x

a data.frame or other compatible object, which includes xts, data.table, tibble, tsibble, and matrix.

...

additional arguments, for instance 'holidays', passed along to tradingDays for calculating the future cloud on daily data.

ticker

(optional) specify a ticker to identify the instrument, otherwise this is set to the name of the input object.

periods

[default c(9L, 26L, 52L)] a vector defining the length of periods used for the cloud. This parameter shoud not normally be modified as using other values would be invalid in the context of traditional ichimoku analysis.

keep.data

(optional) set to TRUE to retain additional data present in the input object as additional columns and/or attributes.

Value

An ichimoku object with S3 classes of 'ichimoku', 'xts' and 'zoo'.

Details

Calling an ichimoku object automatically invokes its print method, which by default produces a printout of the data to the console as well as a plot of the cloud chart to the graphical device.

For further options, use plot() on the returned ichimoku object to pass further arguments for customising the chart. Use iplot() for interactive charting.

Where an ichimoku object is passed to ichimoku(), the ichimoku object is re-calculated using the OHLC pricing data contained within.

Ichimoku Object Specification

Index:

Columns [numeric]:

  • object$open: opening price

  • $high: high price

  • $low: low price

  • $close: closing price

  • $cd: candle direction (-1 = down, 0 = flat, 1 = up)

  • $tenkan: Tenkan-sen

  • $kijun: Kijun-sen

  • $senkouA: Senkou span A

  • $senkouB: Senkou span B

  • $chikou: Chikou span

  • $cloudT: cloud Top (max of senkouA, senkouB)

  • $cloudB: cloud Base (min of senkouA, senkouB)

Attributes:

  • attributes(object)$periods: parameters used to calculate the cloud [integer vector of length 3]

  • $periodicity: periodicity of the data in seconds [numeric]

  • $ticker: instrument identifier [character]

Further Details

ichimoku() requires OHLC (or else HLC) price data as input to calculate the cloud chart values.

If only single series price data is supplied, a pseudo OHLC series is generated and a pseudo cloud chart is returned.

Please refer to the reference vignette by calling: vignette("reference", package = "ichimoku")

Examples

TKR <- sample_ohlc_data cloud <- ichimoku(TKR) plot(cloud)
print(cloud[101:110, ], plot = FALSE)
#> open high low close cd tenkan kijun senkouA senkouB #> 2020-05-20 23:00:00 122.4 122.6 121.1 121.9 -1 121.05 123.90 125.675 124.85 #> 2020-05-21 23:00:00 121.9 123.7 121.7 123.3 1 121.40 123.80 125.675 124.85 #> 2020-05-24 23:00:00 123.3 124.0 123.0 124.0 1 121.55 123.80 125.675 124.85 #> 2020-05-25 23:00:00 124.2 124.3 124.0 124.1 -1 121.75 123.65 125.975 124.85 #> 2020-05-26 23:00:00 124.1 124.1 123.4 123.9 -1 122.25 123.65 126.475 124.85 #> 2020-05-27 23:00:00 123.9 124.7 123.7 124.5 1 122.90 123.65 126.575 124.85 #> 2020-05-28 23:00:00 124.5 124.7 123.9 124.2 -1 122.90 123.60 126.250 124.85 #> 2020-05-31 23:00:00 124.2 125.2 124.0 124.7 1 123.15 123.60 126.150 124.85 #> 2020-06-01 23:00:00 124.7 129.8 124.7 129.6 1 125.45 124.45 125.675 124.85 #> 2020-06-02 23:00:00 129.9 130.6 129.9 130.2 1 126.15 124.85 125.625 124.85 #> chikou cloudT cloudB #> 2020-05-20 23:00:00 135.6 125.675 124.85 #> 2020-05-21 23:00:00 134.5 125.675 124.85 #> 2020-05-24 23:00:00 134.3 125.675 124.85 #> 2020-05-25 23:00:00 135.9 125.975 124.85 #> 2020-05-26 23:00:00 135.2 126.475 124.85 #> 2020-05-27 23:00:00 135.7 126.575 124.85 #> 2020-05-28 23:00:00 135.4 126.250 124.85 #> 2020-05-31 23:00:00 135.7 126.150 124.85 #> 2020-06-01 23:00:00 135.6 125.675 124.85 #> 2020-06-02 23:00:00 136.2 125.625 124.85
kumo <- ichimoku(TKR, ticker = "TKR Co.", periods = c(9, 26, 52), keep.data = TRUE) summary(kumo)
#> ichimoku object with dimensions (281, 13) #> #> Max: 2020-07-13 23:00:00 [139.7] #> Start: 2020-01-02 00:00:00 [123] End: 2020-12-24 00:00:00 [136] #> Min: 2020-05-12 23:00:00 [119.1] #> #> Cloud periods: 9 26 52 #> Periodicity: 1 days #> Ticker: TKR Co.
plot(kumo, theme = "solarized", type = "bar", custom = "volume")