diff --git a/NAMESPACE b/NAMESPACE index 0175c495..90d8b5b0 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -841,6 +841,7 @@ export(kicking_baby_length) export(ladder_bottom) export(long_legged_doji) export(long_line) +export(lookback) export(marubozu) export(mat_hold) export(matching_low) diff --git a/NEWS.md b/NEWS.md index 3ef42aab..f5cca55c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,22 @@ +# version 0.9-3 + +## improvements + +* A new function for pre-calculating the lookback-period has been implemented. It can be used as follows: + +```R +talib::lookback( + FUN = talib::SMA, + n = 10, + x = talib::BTC +) +``` + +The function returns the minimum required lookback for calculating the indicator. +Its use-case is customized control-flows for downstream wrappers and/or packages that declares dependency on {talib}. + +## bug-fixes + # version 0.9-2 ## improvements diff --git a/R/lookback.R b/R/lookback.R new file mode 100644 index 00000000..4e037507 --- /dev/null +++ b/R/lookback.R @@ -0,0 +1,69 @@ +#' @export +#' @family Utility +#' +#' Calculate lookback period +#' +#' @description +#' The function calculates the lookback period for a given +#' indicator. +#' Its primarily meant as a helper function for downstream packages +#' that wants to use a customized control-flow. +#' +#' @examples +#' ## calculate the lookback +#' ## for the bollinger bands +#' talib::lookback( +#' talib::bollinger_bands, +#' n = 20, +#' x = talib::BTC +#' ) +#' +#' @param FUN A [call] or [function]. +#' @param ... Additional parameters passed into the indicator function. See examples for more details. +#' +#' @concept finance +#' @concept technical analysis +#' @concept trading +#' @concept algorithmic trading +#' +#' +#' @author Serkan Korkmaz +#' +#' @returns +#' An [integer] of [length] 1. +lookback <- function( + FUN, + ... +) { + ## store {talib} as a namespace + ## so the function can be found + ## (*_lookback is not exported) + ns <- getNamespace( + "talib" + ) + + ## extract the function call + ## as-is + FUN <- substitute( + FUN + ) + + if (is.call(FUN)) { + FUN <- FUN[[length(FUN)]] + } + + fun_name <- paste0(as.character(FUN), "_lookback") + + if (!exists(fun_name, envir = ns, mode = "function", inherits = FALSE)) { + stop( + "No internal function named `", + fun_name, + "` was found.", + call. = FALSE + ) + } + + FUN <- get(fun_name, envir = ns, mode = "function", inherits = FALSE) + + do.call(FUN, args = list(...)) +} diff --git a/R/ta_ACCBANDS.R b/R/ta_ACCBANDS.R index 82a7d53f..3866b181 100644 --- a/R/ta_ACCBANDS.R +++ b/R/ta_ACCBANDS.R @@ -122,6 +122,38 @@ acceleration_bands.matrix <- function( ) } +#' @usage NULL +ACCBANDS_lookback <- acceleration_bands_lookback <- function( + x, + cols, + n = 20, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_ACCBANDS_lookback, + ## splice:lookback:start + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + as.integer(n) + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases acceleration_bands diff --git a/R/ta_AD.R b/R/ta_AD.R index e0198b40..9b61ff83 100644 --- a/R/ta_AD.R +++ b/R/ta_AD.R @@ -116,6 +116,37 @@ chaikin_accumulation_distribution_line.matrix <- function( ) } +#' @usage NULL +AD_lookback <- chaikin_accumulation_distribution_line_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ high + low + close + volume, + data = x, + ... + ) + + .Call( + C_impl_ta_AD_lookback, + ## splice:lookback:start + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases chaikin_accumulation_distribution_line diff --git a/R/ta_ADOSC.R b/R/ta_ADOSC.R index 953c06a7..1b16d6f7 100644 --- a/R/ta_ADOSC.R +++ b/R/ta_ADOSC.R @@ -132,6 +132,41 @@ chaikin_accumulation_distribution_oscillator.matrix <- function( ) } +#' @usage NULL +ADOSC_lookback <- chaikin_accumulation_distribution_oscillator_lookback <- function( + x, + cols, + fast = 3, + slow = 10, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ high + low + close + volume, + data = x, + ... + ) + + .Call( + C_impl_ta_ADOSC_lookback, + ## splice:lookback:start + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]], + as.integer(fast), + as.integer(slow) + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases chaikin_accumulation_distribution_oscillator diff --git a/R/ta_ADX.R b/R/ta_ADX.R index 9e0b4102..a2a6495c 100644 --- a/R/ta_ADX.R +++ b/R/ta_ADX.R @@ -122,6 +122,38 @@ average_directional_movement_index.matrix <- function( ) } +#' @usage NULL +ADX_lookback <- average_directional_movement_index_lookback <- function( + x, + cols, + n = 14, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_ADX_lookback, + ## splice:lookback:start + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + as.integer(n) + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases average_directional_movement_index diff --git a/R/ta_ADXR.R b/R/ta_ADXR.R index 1022b36c..9923e53c 100644 --- a/R/ta_ADXR.R +++ b/R/ta_ADXR.R @@ -122,6 +122,38 @@ average_directional_movement_index_rating.matrix <- function( ) } +#' @usage NULL +ADXR_lookback <- average_directional_movement_index_rating_lookback <- function( + x, + cols, + n = 14, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_ADXR_lookback, + ## splice:lookback:start + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + as.integer(n) + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases average_directional_movement_index_rating diff --git a/R/ta_APO.R b/R/ta_APO.R index 48bc4085..ea308b0e 100644 --- a/R/ta_APO.R +++ b/R/ta_APO.R @@ -137,6 +137,40 @@ absolute_price_oscillator.matrix <- function( ) } +#' @usage NULL +APO_lookback <- absolute_price_oscillator_lookback <- function( + x, + cols, + fast = 12, + slow = 26, + ma = SMA(n = 9), + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~close, + data = x, + ... + ) + + .Call( + C_impl_ta_APO_lookback, + ## splice:lookback:start + constructed_series[[1]], + as.integer(fast), + as.integer(slow), + ma$maType + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases absolute_price_oscillator @@ -173,7 +207,7 @@ absolute_price_oscillator.numeric <- function( ) if (dim(x)[2] == 1L) { - x <- as.double(x) + dim(x) <- NULL } x diff --git a/R/ta_AROON.R b/R/ta_AROON.R index 0cedc7c0..3b057885 100644 --- a/R/ta_AROON.R +++ b/R/ta_AROON.R @@ -121,6 +121,37 @@ aroon.matrix <- function( ) } +#' @usage NULL +AROON_lookback <- aroon_lookback <- function( + x, + cols, + n = 14, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ high + low, + data = x, + ... + ) + + .Call( + C_impl_ta_AROON_lookback, + ## splice:lookback:start + constructed_series[[1]], + constructed_series[[2]], + as.integer(n) + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases aroon diff --git a/R/ta_AROONOSC.R b/R/ta_AROONOSC.R index 81452a9d..08a4598a 100644 --- a/R/ta_AROONOSC.R +++ b/R/ta_AROONOSC.R @@ -121,6 +121,37 @@ aroon_oscillator.matrix <- function( ) } +#' @usage NULL +AROONOSC_lookback <- aroon_oscillator_lookback <- function( + x, + cols, + n = 14, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ high + low, + data = x, + ... + ) + + .Call( + C_impl_ta_AROONOSC_lookback, + ## splice:lookback:start + constructed_series[[1]], + constructed_series[[2]], + as.integer(n) + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases aroon_oscillator diff --git a/R/ta_ATR.R b/R/ta_ATR.R index 9c1dbbd6..d98f6545 100644 --- a/R/ta_ATR.R +++ b/R/ta_ATR.R @@ -122,6 +122,38 @@ average_true_range.matrix <- function( ) } +#' @usage NULL +ATR_lookback <- average_true_range_lookback <- function( + x, + cols, + n = 14, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_ATR_lookback, + ## splice:lookback:start + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + as.integer(n) + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases average_true_range diff --git a/R/ta_AVGPRICE.R b/R/ta_AVGPRICE.R index 666fd0c6..efcf7e5c 100644 --- a/R/ta_AVGPRICE.R +++ b/R/ta_AVGPRICE.R @@ -115,3 +115,35 @@ average_price.matrix <- function( ... ) } + +#' @usage NULL +AVGPRICE_lookback <- average_price_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_AVGPRICE_lookback, + ## splice:lookback:start + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ## splice:lookback:end + ) +} diff --git a/R/ta_BBANDS.R b/R/ta_BBANDS.R index 3676bb6a..c49b9fca 100644 --- a/R/ta_BBANDS.R +++ b/R/ta_BBANDS.R @@ -145,6 +145,42 @@ bollinger_bands.matrix <- function( ) } +#' @usage NULL +BBANDS_lookback <- bollinger_bands_lookback <- function( + x, + cols, + ma = SMA(n = 5), + sd = 2, + sd_down, + sd_up, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~close, + data = x, + ... + ) + + .Call( + C_impl_ta_BBANDS_lookback, + ## splice:lookback:start + constructed_series[[1]], + ma$n, + as.double(sd_up %or% sd), + as.double(sd_down %or% sd), + ma$maType + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases bollinger_bands @@ -183,7 +219,7 @@ bollinger_bands.numeric <- function( ) if (dim(x)[2] == 1L) { - x <- as.double(x) + dim(x) <- NULL } x diff --git a/R/ta_BETA.R b/R/ta_BETA.R index 78eec1b7..ee3a6c93 100644 --- a/R/ta_BETA.R +++ b/R/ta_BETA.R @@ -49,8 +49,13 @@ rolling_beta.default <- function( as.logical(na.bridge) ) + ## strip dimensions + ## while preserving + ## attributes + dim(x) <- NULL + ## return indicator - as.double(x) + x } #' @usage NULL @@ -72,6 +77,27 @@ rolling_beta.numeric <- function( na.bridge = na.bridge ) + ## strip dimensions + ## while preserving + ## attributes + dim(x) <- NULL + ## return indicator - as.double(x) + x +} + +#' @usage NULL +BETA_lookback <- rolling_beta_lookback <- function( + x, + y, + n = 5 +) { + .Call( + C_impl_ta_BETA_lookback, + ## splice:lookback:start + as.double(x), + as.double(y), + as.integer(n) + ## splice:lookback:end + ) } diff --git a/R/ta_BOP.R b/R/ta_BOP.R index 2e313da8..3e1d5e84 100644 --- a/R/ta_BOP.R +++ b/R/ta_BOP.R @@ -116,6 +116,37 @@ balance_of_power.matrix <- function( ) } +#' @usage NULL +BOP_lookback <- balance_of_power_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_BOP_lookback, + ## splice:lookback:start + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases balance_of_power diff --git a/R/ta_CCI.R b/R/ta_CCI.R index e4b93a9f..c7c1a04e 100644 --- a/R/ta_CCI.R +++ b/R/ta_CCI.R @@ -122,6 +122,38 @@ commodity_channel_index.matrix <- function( ) } +#' @usage NULL +CCI_lookback <- commodity_channel_index_lookback <- function( + x, + cols, + n = 14, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CCI_lookback, + ## splice:lookback:start + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + as.integer(n) + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases commodity_channel_index diff --git a/R/ta_CDL2CROWS.R b/R/ta_CDL2CROWS.R index 1697f99c..c79c556d 100644 --- a/R/ta_CDL2CROWS.R +++ b/R/ta_CDL2CROWS.R @@ -132,6 +132,36 @@ two_crows.matrix <- function( NextMethod() } +#' @usage NULL +CDL2CROWS_lookback <- two_crows_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDL2CROWS_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases two_crows #' diff --git a/R/ta_CDL3BLACKCROWS.R b/R/ta_CDL3BLACKCROWS.R index a3f46cea..4aeb645d 100644 --- a/R/ta_CDL3BLACKCROWS.R +++ b/R/ta_CDL3BLACKCROWS.R @@ -132,6 +132,36 @@ three_black_crows.matrix <- function( NextMethod() } +#' @usage NULL +CDL3BLACKCROWS_lookback <- three_black_crows_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDL3BLACKCROWS_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases three_black_crows #' diff --git a/R/ta_CDL3INSIDE.R b/R/ta_CDL3INSIDE.R index cd46e330..cf1dffd3 100644 --- a/R/ta_CDL3INSIDE.R +++ b/R/ta_CDL3INSIDE.R @@ -132,6 +132,36 @@ three_inside.matrix <- function( NextMethod() } +#' @usage NULL +CDL3INSIDE_lookback <- three_inside_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDL3INSIDE_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases three_inside #' diff --git a/R/ta_CDL3LINESTRIKE.R b/R/ta_CDL3LINESTRIKE.R index ac54cdbb..13dc938f 100644 --- a/R/ta_CDL3LINESTRIKE.R +++ b/R/ta_CDL3LINESTRIKE.R @@ -132,6 +132,36 @@ three_line_strike.matrix <- function( NextMethod() } +#' @usage NULL +CDL3LINESTRIKE_lookback <- three_line_strike_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDL3LINESTRIKE_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases three_line_strike #' diff --git a/R/ta_CDL3OUTSIDE.R b/R/ta_CDL3OUTSIDE.R index 872ce706..13afe056 100644 --- a/R/ta_CDL3OUTSIDE.R +++ b/R/ta_CDL3OUTSIDE.R @@ -132,6 +132,36 @@ three_outside.matrix <- function( NextMethod() } +#' @usage NULL +CDL3OUTSIDE_lookback <- three_outside_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDL3OUTSIDE_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases three_outside #' diff --git a/R/ta_CDL3STARSINSOUTH.R b/R/ta_CDL3STARSINSOUTH.R index bf6fbc1e..2215b176 100644 --- a/R/ta_CDL3STARSINSOUTH.R +++ b/R/ta_CDL3STARSINSOUTH.R @@ -132,6 +132,36 @@ three_stars_in_the_south.matrix <- function( NextMethod() } +#' @usage NULL +CDL3STARSINSOUTH_lookback <- three_stars_in_the_south_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDL3STARSINSOUTH_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases three_stars_in_the_south #' diff --git a/R/ta_CDL3WHITESOLDIERS.R b/R/ta_CDL3WHITESOLDIERS.R index 3d800b3f..9e4c3542 100644 --- a/R/ta_CDL3WHITESOLDIERS.R +++ b/R/ta_CDL3WHITESOLDIERS.R @@ -132,6 +132,36 @@ three_white_soldiers.matrix <- function( NextMethod() } +#' @usage NULL +CDL3WHITESOLDIERS_lookback <- three_white_soldiers_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDL3WHITESOLDIERS_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases three_white_soldiers #' diff --git a/R/ta_CDLABANDONEDBABY.R b/R/ta_CDLABANDONEDBABY.R index 5decd688..a3ec95c7 100644 --- a/R/ta_CDLABANDONEDBABY.R +++ b/R/ta_CDLABANDONEDBABY.R @@ -137,6 +137,38 @@ abandoned_baby.matrix <- function( NextMethod() } +#' @usage NULL +CDLABANDONEDBABY_lookback <- abandoned_baby_lookback <- function( + x, + cols, + eps = 0, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLABANDONEDBABY_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]], + eps + ) +} + #' @usage NULL #' @aliases abandoned_baby #' diff --git a/R/ta_CDLADVANCEBLOCK.R b/R/ta_CDLADVANCEBLOCK.R index 7ffa59eb..16c10bca 100644 --- a/R/ta_CDLADVANCEBLOCK.R +++ b/R/ta_CDLADVANCEBLOCK.R @@ -132,6 +132,36 @@ advance_block.matrix <- function( NextMethod() } +#' @usage NULL +CDLADVANCEBLOCK_lookback <- advance_block_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLADVANCEBLOCK_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases advance_block #' diff --git a/R/ta_CDLBELTHOLD.R b/R/ta_CDLBELTHOLD.R index d241985d..8e3a056d 100644 --- a/R/ta_CDLBELTHOLD.R +++ b/R/ta_CDLBELTHOLD.R @@ -132,6 +132,36 @@ belt_hold.matrix <- function( NextMethod() } +#' @usage NULL +CDLBELTHOLD_lookback <- belt_hold_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLBELTHOLD_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases belt_hold #' diff --git a/R/ta_CDLBREAKAWAY.R b/R/ta_CDLBREAKAWAY.R index 05fd11f8..d90f1f10 100644 --- a/R/ta_CDLBREAKAWAY.R +++ b/R/ta_CDLBREAKAWAY.R @@ -132,6 +132,36 @@ break_away.matrix <- function( NextMethod() } +#' @usage NULL +CDLBREAKAWAY_lookback <- break_away_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLBREAKAWAY_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases break_away #' diff --git a/R/ta_CDLCLOSINGMARUBOZU.R b/R/ta_CDLCLOSINGMARUBOZU.R index 8c12755f..c26fa329 100644 --- a/R/ta_CDLCLOSINGMARUBOZU.R +++ b/R/ta_CDLCLOSINGMARUBOZU.R @@ -132,6 +132,36 @@ closing_marubozu.matrix <- function( NextMethod() } +#' @usage NULL +CDLCLOSINGMARUBOZU_lookback <- closing_marubozu_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLCLOSINGMARUBOZU_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases closing_marubozu #' diff --git a/R/ta_CDLCONCEALBABYSWALL.R b/R/ta_CDLCONCEALBABYSWALL.R index 1abe7754..bcccd5ab 100644 --- a/R/ta_CDLCONCEALBABYSWALL.R +++ b/R/ta_CDLCONCEALBABYSWALL.R @@ -132,6 +132,36 @@ concealing_baby_swallow.matrix <- function( NextMethod() } +#' @usage NULL +CDLCONCEALBABYSWALL_lookback <- concealing_baby_swallow_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLCONCEALBABYSWALL_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases concealing_baby_swallow #' diff --git a/R/ta_CDLCOUNTERATTACK.R b/R/ta_CDLCOUNTERATTACK.R index 3fb8660c..70365419 100644 --- a/R/ta_CDLCOUNTERATTACK.R +++ b/R/ta_CDLCOUNTERATTACK.R @@ -132,6 +132,36 @@ counter_attack.matrix <- function( NextMethod() } +#' @usage NULL +CDLCOUNTERATTACK_lookback <- counter_attack_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLCOUNTERATTACK_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases counter_attack #' diff --git a/R/ta_CDLDARKCLOUDCOVER.R b/R/ta_CDLDARKCLOUDCOVER.R index b56bd511..553c1a7c 100644 --- a/R/ta_CDLDARKCLOUDCOVER.R +++ b/R/ta_CDLDARKCLOUDCOVER.R @@ -137,6 +137,38 @@ dark_cloud_cover.matrix <- function( NextMethod() } +#' @usage NULL +CDLDARKCLOUDCOVER_lookback <- dark_cloud_cover_lookback <- function( + x, + cols, + eps = 0, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLDARKCLOUDCOVER_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]], + eps + ) +} + #' @usage NULL #' @aliases dark_cloud_cover #' diff --git a/R/ta_CDLDOJI.R b/R/ta_CDLDOJI.R index 2ca3a500..da7c64f1 100644 --- a/R/ta_CDLDOJI.R +++ b/R/ta_CDLDOJI.R @@ -132,6 +132,36 @@ doji.matrix <- function( NextMethod() } +#' @usage NULL +CDLDOJI_lookback <- doji_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLDOJI_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases doji #' diff --git a/R/ta_CDLDOJISTAR.R b/R/ta_CDLDOJISTAR.R index 9691c0ef..6a6656a0 100644 --- a/R/ta_CDLDOJISTAR.R +++ b/R/ta_CDLDOJISTAR.R @@ -132,6 +132,36 @@ doji_star.matrix <- function( NextMethod() } +#' @usage NULL +CDLDOJISTAR_lookback <- doji_star_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLDOJISTAR_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases doji_star #' diff --git a/R/ta_CDLDRAGONFLYDOJI.R b/R/ta_CDLDRAGONFLYDOJI.R index 60253086..bba237b4 100644 --- a/R/ta_CDLDRAGONFLYDOJI.R +++ b/R/ta_CDLDRAGONFLYDOJI.R @@ -132,6 +132,36 @@ dragonfly_doji.matrix <- function( NextMethod() } +#' @usage NULL +CDLDRAGONFLYDOJI_lookback <- dragonfly_doji_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLDRAGONFLYDOJI_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases dragonfly_doji #' diff --git a/R/ta_CDLENGULFING.R b/R/ta_CDLENGULFING.R index 24038dd3..770935ea 100644 --- a/R/ta_CDLENGULFING.R +++ b/R/ta_CDLENGULFING.R @@ -132,6 +132,36 @@ engulfing.matrix <- function( NextMethod() } +#' @usage NULL +CDLENGULFING_lookback <- engulfing_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLENGULFING_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases engulfing #' diff --git a/R/ta_CDLEVENINGDOJISTAR.R b/R/ta_CDLEVENINGDOJISTAR.R index 907656aa..d2378904 100644 --- a/R/ta_CDLEVENINGDOJISTAR.R +++ b/R/ta_CDLEVENINGDOJISTAR.R @@ -137,6 +137,38 @@ evening_doji_star.matrix <- function( NextMethod() } +#' @usage NULL +CDLEVENINGDOJISTAR_lookback <- evening_doji_star_lookback <- function( + x, + cols, + eps = 0, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLEVENINGDOJISTAR_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]], + eps + ) +} + #' @usage NULL #' @aliases evening_doji_star #' diff --git a/R/ta_CDLEVENINGSTAR.R b/R/ta_CDLEVENINGSTAR.R index 94402024..1c6e9db5 100644 --- a/R/ta_CDLEVENINGSTAR.R +++ b/R/ta_CDLEVENINGSTAR.R @@ -137,6 +137,38 @@ evening_star.matrix <- function( NextMethod() } +#' @usage NULL +CDLEVENINGSTAR_lookback <- evening_star_lookback <- function( + x, + cols, + eps = 0, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLEVENINGSTAR_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]], + eps + ) +} + #' @usage NULL #' @aliases evening_star #' diff --git a/R/ta_CDLGAPSIDESIDEWHITE.R b/R/ta_CDLGAPSIDESIDEWHITE.R index 50410f78..1caf72e0 100644 --- a/R/ta_CDLGAPSIDESIDEWHITE.R +++ b/R/ta_CDLGAPSIDESIDEWHITE.R @@ -132,6 +132,36 @@ gaps_side_white.matrix <- function( NextMethod() } +#' @usage NULL +CDLGAPSIDESIDEWHITE_lookback <- gaps_side_white_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLGAPSIDESIDEWHITE_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases gaps_side_white #' diff --git a/R/ta_CDLGRAVESTONEDOJI.R b/R/ta_CDLGRAVESTONEDOJI.R index 93116307..3bbf10d6 100644 --- a/R/ta_CDLGRAVESTONEDOJI.R +++ b/R/ta_CDLGRAVESTONEDOJI.R @@ -132,6 +132,36 @@ gravestone_doji.matrix <- function( NextMethod() } +#' @usage NULL +CDLGRAVESTONEDOJI_lookback <- gravestone_doji_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLGRAVESTONEDOJI_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases gravestone_doji #' diff --git a/R/ta_CDLHAMMER.R b/R/ta_CDLHAMMER.R index bf74d041..f129e628 100644 --- a/R/ta_CDLHAMMER.R +++ b/R/ta_CDLHAMMER.R @@ -132,6 +132,36 @@ hammer.matrix <- function( NextMethod() } +#' @usage NULL +CDLHAMMER_lookback <- hammer_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLHAMMER_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases hammer #' diff --git a/R/ta_CDLHANGINGMAN.R b/R/ta_CDLHANGINGMAN.R index 42732517..464d17b6 100644 --- a/R/ta_CDLHANGINGMAN.R +++ b/R/ta_CDLHANGINGMAN.R @@ -132,6 +132,36 @@ hanging_man.matrix <- function( NextMethod() } +#' @usage NULL +CDLHANGINGMAN_lookback <- hanging_man_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLHANGINGMAN_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases hanging_man #' diff --git a/R/ta_CDLHARAMI.R b/R/ta_CDLHARAMI.R index 0e1a5403..d27ef964 100644 --- a/R/ta_CDLHARAMI.R +++ b/R/ta_CDLHARAMI.R @@ -132,6 +132,36 @@ harami.matrix <- function( NextMethod() } +#' @usage NULL +CDLHARAMI_lookback <- harami_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLHARAMI_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases harami #' diff --git a/R/ta_CDLHARAMICROSS.R b/R/ta_CDLHARAMICROSS.R index 749141b9..73e808e0 100644 --- a/R/ta_CDLHARAMICROSS.R +++ b/R/ta_CDLHARAMICROSS.R @@ -132,6 +132,36 @@ harami_cross.matrix <- function( NextMethod() } +#' @usage NULL +CDLHARAMICROSS_lookback <- harami_cross_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLHARAMICROSS_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases harami_cross #' diff --git a/R/ta_CDLHIGHWAVE.R b/R/ta_CDLHIGHWAVE.R index 17100b4e..6c344513 100644 --- a/R/ta_CDLHIGHWAVE.R +++ b/R/ta_CDLHIGHWAVE.R @@ -132,6 +132,36 @@ high_wave.matrix <- function( NextMethod() } +#' @usage NULL +CDLHIGHWAVE_lookback <- high_wave_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLHIGHWAVE_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases high_wave #' diff --git a/R/ta_CDLHIKKAKE.R b/R/ta_CDLHIKKAKE.R index f5e218e4..620a7d9b 100644 --- a/R/ta_CDLHIKKAKE.R +++ b/R/ta_CDLHIKKAKE.R @@ -132,6 +132,36 @@ hikakke.matrix <- function( NextMethod() } +#' @usage NULL +CDLHIKKAKE_lookback <- hikakke_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLHIKKAKE_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases hikakke #' diff --git a/R/ta_CDLHIKKAKEMOD.R b/R/ta_CDLHIKKAKEMOD.R index 43fdab5e..d5bc0e46 100644 --- a/R/ta_CDLHIKKAKEMOD.R +++ b/R/ta_CDLHIKKAKEMOD.R @@ -132,6 +132,36 @@ hikakke_mod.matrix <- function( NextMethod() } +#' @usage NULL +CDLHIKKAKEMOD_lookback <- hikakke_mod_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLHIKKAKEMOD_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases hikakke_mod #' diff --git a/R/ta_CDLHOMINGPIGEON.R b/R/ta_CDLHOMINGPIGEON.R index 82566f6b..aa59697f 100644 --- a/R/ta_CDLHOMINGPIGEON.R +++ b/R/ta_CDLHOMINGPIGEON.R @@ -132,6 +132,36 @@ homing_pigeon.matrix <- function( NextMethod() } +#' @usage NULL +CDLHOMINGPIGEON_lookback <- homing_pigeon_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLHOMINGPIGEON_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases homing_pigeon #' diff --git a/R/ta_CDLIDENTICAL3CROWS.R b/R/ta_CDLIDENTICAL3CROWS.R index 6d53e8b4..f53a6001 100644 --- a/R/ta_CDLIDENTICAL3CROWS.R +++ b/R/ta_CDLIDENTICAL3CROWS.R @@ -132,6 +132,36 @@ three_identical_crows.matrix <- function( NextMethod() } +#' @usage NULL +CDLIDENTICAL3CROWS_lookback <- three_identical_crows_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLIDENTICAL3CROWS_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases three_identical_crows #' diff --git a/R/ta_CDLINNECK.R b/R/ta_CDLINNECK.R index 0ad45078..ae93052c 100644 --- a/R/ta_CDLINNECK.R +++ b/R/ta_CDLINNECK.R @@ -132,6 +132,36 @@ in_neck.matrix <- function( NextMethod() } +#' @usage NULL +CDLINNECK_lookback <- in_neck_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLINNECK_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases in_neck #' diff --git a/R/ta_CDLINVERTEDHAMMER.R b/R/ta_CDLINVERTEDHAMMER.R index 46b28e3a..6013b62b 100644 --- a/R/ta_CDLINVERTEDHAMMER.R +++ b/R/ta_CDLINVERTEDHAMMER.R @@ -132,6 +132,36 @@ inverted_hammer.matrix <- function( NextMethod() } +#' @usage NULL +CDLINVERTEDHAMMER_lookback <- inverted_hammer_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLINVERTEDHAMMER_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases inverted_hammer #' diff --git a/R/ta_CDLKICKING.R b/R/ta_CDLKICKING.R index 079feb38..027447af 100644 --- a/R/ta_CDLKICKING.R +++ b/R/ta_CDLKICKING.R @@ -132,6 +132,36 @@ kicking.matrix <- function( NextMethod() } +#' @usage NULL +CDLKICKING_lookback <- kicking_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLKICKING_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases kicking #' diff --git a/R/ta_CDLKICKINGBYLENGTH.R b/R/ta_CDLKICKINGBYLENGTH.R index 9e60f5a5..694df66e 100644 --- a/R/ta_CDLKICKINGBYLENGTH.R +++ b/R/ta_CDLKICKINGBYLENGTH.R @@ -132,6 +132,36 @@ kicking_baby_length.matrix <- function( NextMethod() } +#' @usage NULL +CDLKICKINGBYLENGTH_lookback <- kicking_baby_length_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLKICKINGBYLENGTH_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases kicking_baby_length #' diff --git a/R/ta_CDLLADDERBOTTOM.R b/R/ta_CDLLADDERBOTTOM.R index a43a9cf4..f844980a 100644 --- a/R/ta_CDLLADDERBOTTOM.R +++ b/R/ta_CDLLADDERBOTTOM.R @@ -132,6 +132,36 @@ ladder_bottom.matrix <- function( NextMethod() } +#' @usage NULL +CDLLADDERBOTTOM_lookback <- ladder_bottom_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLLADDERBOTTOM_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases ladder_bottom #' diff --git a/R/ta_CDLLONGLEGGEDDOJI.R b/R/ta_CDLLONGLEGGEDDOJI.R index 342e5c13..86e1274b 100644 --- a/R/ta_CDLLONGLEGGEDDOJI.R +++ b/R/ta_CDLLONGLEGGEDDOJI.R @@ -132,6 +132,36 @@ long_legged_doji.matrix <- function( NextMethod() } +#' @usage NULL +CDLLONGLEGGEDDOJI_lookback <- long_legged_doji_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLLONGLEGGEDDOJI_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases long_legged_doji #' diff --git a/R/ta_CDLLONGLINE.R b/R/ta_CDLLONGLINE.R index 7c907f73..57c3adbd 100644 --- a/R/ta_CDLLONGLINE.R +++ b/R/ta_CDLLONGLINE.R @@ -132,6 +132,36 @@ long_line.matrix <- function( NextMethod() } +#' @usage NULL +CDLLONGLINE_lookback <- long_line_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLLONGLINE_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases long_line #' diff --git a/R/ta_CDLMARUBOZU.R b/R/ta_CDLMARUBOZU.R index fe592ac3..a5f6eb9f 100644 --- a/R/ta_CDLMARUBOZU.R +++ b/R/ta_CDLMARUBOZU.R @@ -132,6 +132,36 @@ marubozu.matrix <- function( NextMethod() } +#' @usage NULL +CDLMARUBOZU_lookback <- marubozu_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLMARUBOZU_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases marubozu #' diff --git a/R/ta_CDLMATCHINGLOW.R b/R/ta_CDLMATCHINGLOW.R index c1aab57d..92b4f528 100644 --- a/R/ta_CDLMATCHINGLOW.R +++ b/R/ta_CDLMATCHINGLOW.R @@ -132,6 +132,36 @@ matching_low.matrix <- function( NextMethod() } +#' @usage NULL +CDLMATCHINGLOW_lookback <- matching_low_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLMATCHINGLOW_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases matching_low #' diff --git a/R/ta_CDLMATHOLD.R b/R/ta_CDLMATHOLD.R index afe98eab..15ea8f52 100644 --- a/R/ta_CDLMATHOLD.R +++ b/R/ta_CDLMATHOLD.R @@ -137,6 +137,38 @@ mat_hold.matrix <- function( NextMethod() } +#' @usage NULL +CDLMATHOLD_lookback <- mat_hold_lookback <- function( + x, + cols, + eps = 0, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLMATHOLD_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]], + eps + ) +} + #' @usage NULL #' @aliases mat_hold #' diff --git a/R/ta_CDLMORNINGDOJISTAR.R b/R/ta_CDLMORNINGDOJISTAR.R index 5aa05cb8..6de0f62d 100644 --- a/R/ta_CDLMORNINGDOJISTAR.R +++ b/R/ta_CDLMORNINGDOJISTAR.R @@ -137,6 +137,38 @@ morning_doji_star.matrix <- function( NextMethod() } +#' @usage NULL +CDLMORNINGDOJISTAR_lookback <- morning_doji_star_lookback <- function( + x, + cols, + eps = 0, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLMORNINGDOJISTAR_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]], + eps + ) +} + #' @usage NULL #' @aliases morning_doji_star #' diff --git a/R/ta_CDLMORNINGSTAR.R b/R/ta_CDLMORNINGSTAR.R index d2fd1720..aa5404d8 100644 --- a/R/ta_CDLMORNINGSTAR.R +++ b/R/ta_CDLMORNINGSTAR.R @@ -137,6 +137,38 @@ morning_star.matrix <- function( NextMethod() } +#' @usage NULL +CDLMORNINGSTAR_lookback <- morning_star_lookback <- function( + x, + cols, + eps = 0, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLMORNINGSTAR_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]], + eps + ) +} + #' @usage NULL #' @aliases morning_star #' diff --git a/R/ta_CDLONNECK.R b/R/ta_CDLONNECK.R index 4d9ed7fe..dde28b5b 100644 --- a/R/ta_CDLONNECK.R +++ b/R/ta_CDLONNECK.R @@ -132,6 +132,36 @@ on_neck.matrix <- function( NextMethod() } +#' @usage NULL +CDLONNECK_lookback <- on_neck_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLONNECK_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases on_neck #' diff --git a/R/ta_CDLPIERCING.R b/R/ta_CDLPIERCING.R index 5df9f133..a5fda994 100644 --- a/R/ta_CDLPIERCING.R +++ b/R/ta_CDLPIERCING.R @@ -132,6 +132,36 @@ piercing.matrix <- function( NextMethod() } +#' @usage NULL +CDLPIERCING_lookback <- piercing_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLPIERCING_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases piercing #' diff --git a/R/ta_CDLRICKSHAWMAN.R b/R/ta_CDLRICKSHAWMAN.R index f96e1357..093178af 100644 --- a/R/ta_CDLRICKSHAWMAN.R +++ b/R/ta_CDLRICKSHAWMAN.R @@ -132,6 +132,36 @@ rickshaw_man.matrix <- function( NextMethod() } +#' @usage NULL +CDLRICKSHAWMAN_lookback <- rickshaw_man_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLRICKSHAWMAN_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases rickshaw_man #' diff --git a/R/ta_CDLRISEFALL3METHODS.R b/R/ta_CDLRISEFALL3METHODS.R index 116fa14e..279bd00c 100644 --- a/R/ta_CDLRISEFALL3METHODS.R +++ b/R/ta_CDLRISEFALL3METHODS.R @@ -132,6 +132,36 @@ rise_fall_3_methods.matrix <- function( NextMethod() } +#' @usage NULL +CDLRISEFALL3METHODS_lookback <- rise_fall_3_methods_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLRISEFALL3METHODS_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases rise_fall_3_methods #' diff --git a/R/ta_CDLSEPARATINGLINES.R b/R/ta_CDLSEPARATINGLINES.R index e0ff5f76..878c9d22 100644 --- a/R/ta_CDLSEPARATINGLINES.R +++ b/R/ta_CDLSEPARATINGLINES.R @@ -132,6 +132,36 @@ separating_lines.matrix <- function( NextMethod() } +#' @usage NULL +CDLSEPARATINGLINES_lookback <- separating_lines_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLSEPARATINGLINES_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases separating_lines #' diff --git a/R/ta_CDLSHOOTINGSTAR.R b/R/ta_CDLSHOOTINGSTAR.R index a99cea3f..ba4fadd0 100644 --- a/R/ta_CDLSHOOTINGSTAR.R +++ b/R/ta_CDLSHOOTINGSTAR.R @@ -132,6 +132,36 @@ shooting_star.matrix <- function( NextMethod() } +#' @usage NULL +CDLSHOOTINGSTAR_lookback <- shooting_star_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLSHOOTINGSTAR_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases shooting_star #' diff --git a/R/ta_CDLSHORTLINE.R b/R/ta_CDLSHORTLINE.R index c5dd4c8b..749d270f 100644 --- a/R/ta_CDLSHORTLINE.R +++ b/R/ta_CDLSHORTLINE.R @@ -132,6 +132,36 @@ short_line.matrix <- function( NextMethod() } +#' @usage NULL +CDLSHORTLINE_lookback <- short_line_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLSHORTLINE_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases short_line #' diff --git a/R/ta_CDLSPINNINGTOP.R b/R/ta_CDLSPINNINGTOP.R index cfb3609d..f21273aa 100644 --- a/R/ta_CDLSPINNINGTOP.R +++ b/R/ta_CDLSPINNINGTOP.R @@ -132,6 +132,36 @@ spinning_top.matrix <- function( NextMethod() } +#' @usage NULL +CDLSPINNINGTOP_lookback <- spinning_top_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLSPINNINGTOP_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases spinning_top #' diff --git a/R/ta_CDLSTALLEDPATTERN.R b/R/ta_CDLSTALLEDPATTERN.R index 472c88d0..85562201 100644 --- a/R/ta_CDLSTALLEDPATTERN.R +++ b/R/ta_CDLSTALLEDPATTERN.R @@ -132,6 +132,36 @@ stalled_pattern.matrix <- function( NextMethod() } +#' @usage NULL +CDLSTALLEDPATTERN_lookback <- stalled_pattern_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLSTALLEDPATTERN_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases stalled_pattern #' diff --git a/R/ta_CDLSTICKSANDWICH.R b/R/ta_CDLSTICKSANDWICH.R index 75b91ed4..2c27022f 100644 --- a/R/ta_CDLSTICKSANDWICH.R +++ b/R/ta_CDLSTICKSANDWICH.R @@ -132,6 +132,36 @@ stick_sandwich.matrix <- function( NextMethod() } +#' @usage NULL +CDLSTICKSANDWICH_lookback <- stick_sandwich_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLSTICKSANDWICH_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases stick_sandwich #' diff --git a/R/ta_CDLTAKURI.R b/R/ta_CDLTAKURI.R index da480fd6..313cd90b 100644 --- a/R/ta_CDLTAKURI.R +++ b/R/ta_CDLTAKURI.R @@ -132,6 +132,36 @@ takuri.matrix <- function( NextMethod() } +#' @usage NULL +CDLTAKURI_lookback <- takuri_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLTAKURI_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases takuri #' diff --git a/R/ta_CDLTASUKIGAP.R b/R/ta_CDLTASUKIGAP.R index 5ecd06ca..4a6e25fe 100644 --- a/R/ta_CDLTASUKIGAP.R +++ b/R/ta_CDLTASUKIGAP.R @@ -132,6 +132,36 @@ tasuki_gap.matrix <- function( NextMethod() } +#' @usage NULL +CDLTASUKIGAP_lookback <- tasuki_gap_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLTASUKIGAP_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases tasuki_gap #' diff --git a/R/ta_CDLTHRUSTING.R b/R/ta_CDLTHRUSTING.R index 08b496e3..3c2341de 100644 --- a/R/ta_CDLTHRUSTING.R +++ b/R/ta_CDLTHRUSTING.R @@ -132,6 +132,36 @@ thrusting.matrix <- function( NextMethod() } +#' @usage NULL +CDLTHRUSTING_lookback <- thrusting_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLTHRUSTING_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases thrusting #' diff --git a/R/ta_CDLTRISTAR.R b/R/ta_CDLTRISTAR.R index fb99feee..8144bea0 100644 --- a/R/ta_CDLTRISTAR.R +++ b/R/ta_CDLTRISTAR.R @@ -132,6 +132,36 @@ tristar.matrix <- function( NextMethod() } +#' @usage NULL +CDLTRISTAR_lookback <- tristar_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLTRISTAR_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases tristar #' diff --git a/R/ta_CDLUNIQUE3RIVER.R b/R/ta_CDLUNIQUE3RIVER.R index ee608e3c..a1634801 100644 --- a/R/ta_CDLUNIQUE3RIVER.R +++ b/R/ta_CDLUNIQUE3RIVER.R @@ -132,6 +132,36 @@ unique_3_river.matrix <- function( NextMethod() } +#' @usage NULL +CDLUNIQUE3RIVER_lookback <- unique_3_river_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLUNIQUE3RIVER_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases unique_3_river #' diff --git a/R/ta_CDLUPSIDEGAP2CROWS.R b/R/ta_CDLUPSIDEGAP2CROWS.R index 977c2b4e..35f32c0c 100644 --- a/R/ta_CDLUPSIDEGAP2CROWS.R +++ b/R/ta_CDLUPSIDEGAP2CROWS.R @@ -132,6 +132,36 @@ upside_gap_2_crows.matrix <- function( NextMethod() } +#' @usage NULL +CDLUPSIDEGAP2CROWS_lookback <- upside_gap_2_crows_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLUPSIDEGAP2CROWS_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases upside_gap_2_crows #' diff --git a/R/ta_CDLXSIDEGAP3METHODS.R b/R/ta_CDLXSIDEGAP3METHODS.R index ee6fa308..3ae89e58 100644 --- a/R/ta_CDLXSIDEGAP3METHODS.R +++ b/R/ta_CDLXSIDEGAP3METHODS.R @@ -132,6 +132,36 @@ xside_gap_3_methods.matrix <- function( NextMethod() } +#' @usage NULL +CDLXSIDEGAP3METHODS_lookback <- xside_gap_3_methods_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_CDLXSIDEGAP3METHODS_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] + ) +} + #' @usage NULL #' @aliases xside_gap_3_methods #' diff --git a/R/ta_CMO.R b/R/ta_CMO.R index 21301770..56575b83 100644 --- a/R/ta_CMO.R +++ b/R/ta_CMO.R @@ -120,6 +120,36 @@ chande_momentum_oscillator.matrix <- function( ) } +#' @usage NULL +CMO_lookback <- chande_momentum_oscillator_lookback <- function( + x, + cols, + n = 14, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~close, + data = x, + ... + ) + + .Call( + C_impl_ta_CMO_lookback, + ## splice:lookback:start + constructed_series[[1]], + as.integer(n) + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases chande_momentum_oscillator @@ -152,7 +182,7 @@ chande_momentum_oscillator.numeric <- function( ) if (dim(x)[2] == 1L) { - x <- as.double(x) + dim(x) <- NULL } x diff --git a/R/ta_CORREL.R b/R/ta_CORREL.R index ebfabfb6..a4b15df4 100644 --- a/R/ta_CORREL.R +++ b/R/ta_CORREL.R @@ -49,8 +49,13 @@ rolling_correlation.default <- function( as.logical(na.bridge) ) + ## strip dimensions + ## while preserving + ## attributes + dim(x) <- NULL + ## return indicator - as.double(x) + x } #' @usage NULL @@ -72,6 +77,27 @@ rolling_correlation.numeric <- function( na.bridge = na.bridge ) + ## strip dimensions + ## while preserving + ## attributes + dim(x) <- NULL + ## return indicator - as.double(x) + x +} + +#' @usage NULL +CORREL_lookback <- rolling_correlation_lookback <- function( + x, + y, + n = 30 +) { + .Call( + C_impl_ta_CORREL_lookback, + ## splice:lookback:start + as.double(x), + as.double(y), + as.integer(n) + ## splice:lookback:end + ) } diff --git a/R/ta_DEMA.R b/R/ta_DEMA.R index e7d0a423..a52d0f60 100644 --- a/R/ta_DEMA.R +++ b/R/ta_DEMA.R @@ -164,12 +164,43 @@ double_exponential_moving_average.numeric <- function( ) if (dim(x)[2] == 1L) { - x <- as.double(x) + dim(x) <- NULL } x } +#' @usage NULL +DEMA_lookback <- double_exponential_moving_average_lookback <- function( + x, + cols, + n = 30, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~close, + data = x, + ... + ) + + .Call( + C_impl_ta_DEMA_lookback, + ## splice:lookback:start + as.double(constructed_series[[1]]), + as.integer(n) + ## splice:lookback:end + ) +} + #' @usage NULL #' @aliases double_exponential_moving_average #' diff --git a/R/ta_DX.R b/R/ta_DX.R index 1db4d604..22788b76 100644 --- a/R/ta_DX.R +++ b/R/ta_DX.R @@ -122,6 +122,38 @@ directional_movement_index.matrix <- function( ) } +#' @usage NULL +DX_lookback <- directional_movement_index_lookback <- function( + x, + cols, + n = 14, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_DX_lookback, + ## splice:lookback:start + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + as.integer(n) + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases directional_movement_index diff --git a/R/ta_EMA.R b/R/ta_EMA.R index e999fc54..c9c285f2 100644 --- a/R/ta_EMA.R +++ b/R/ta_EMA.R @@ -164,12 +164,43 @@ exponential_moving_average.numeric <- function( ) if (dim(x)[2] == 1L) { - x <- as.double(x) + dim(x) <- NULL } x } +#' @usage NULL +EMA_lookback <- exponential_moving_average_lookback <- function( + x, + cols, + n = 30, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~close, + data = x, + ... + ) + + .Call( + C_impl_ta_EMA_lookback, + ## splice:lookback:start + as.double(constructed_series[[1]]), + as.integer(n) + ## splice:lookback:end + ) +} + #' @usage NULL #' @aliases exponential_moving_average #' diff --git a/R/ta_HT_DCPERIOD.R b/R/ta_HT_DCPERIOD.R index d65003f8..4df7ed2e 100644 --- a/R/ta_HT_DCPERIOD.R +++ b/R/ta_HT_DCPERIOD.R @@ -113,6 +113,34 @@ dominant_cycle_period.matrix <- function( ) } +#' @usage NULL +HT_DCPERIOD_lookback <- dominant_cycle_period_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~close, + data = x, + ... + ) + + .Call( + C_impl_ta_HT_DCPERIOD_lookback, + ## splice:lookback:start + constructed_series[[1]] + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases dominant_cycle_period @@ -143,7 +171,7 @@ dominant_cycle_period.numeric <- function( ) if (dim(x)[2] == 1L) { - x <- as.double(x) + dim(x) <- NULL } x diff --git a/R/ta_HT_DCPHASE.R b/R/ta_HT_DCPHASE.R index 401954a8..2b7edbc1 100644 --- a/R/ta_HT_DCPHASE.R +++ b/R/ta_HT_DCPHASE.R @@ -113,6 +113,34 @@ dominant_cycle_phase.matrix <- function( ) } +#' @usage NULL +HT_DCPHASE_lookback <- dominant_cycle_phase_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~close, + data = x, + ... + ) + + .Call( + C_impl_ta_HT_DCPHASE_lookback, + ## splice:lookback:start + constructed_series[[1]] + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases dominant_cycle_phase @@ -143,7 +171,7 @@ dominant_cycle_phase.numeric <- function( ) if (dim(x)[2] == 1L) { - x <- as.double(x) + dim(x) <- NULL } x diff --git a/R/ta_HT_PHASOR.R b/R/ta_HT_PHASOR.R index f2984771..88acf387 100644 --- a/R/ta_HT_PHASOR.R +++ b/R/ta_HT_PHASOR.R @@ -113,6 +113,34 @@ phasor_components.matrix <- function( ) } +#' @usage NULL +HT_PHASOR_lookback <- phasor_components_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~close, + data = x, + ... + ) + + .Call( + C_impl_ta_HT_PHASOR_lookback, + ## splice:lookback:start + constructed_series[[1]] + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases phasor_components @@ -143,7 +171,7 @@ phasor_components.numeric <- function( ) if (dim(x)[2] == 1L) { - x <- as.double(x) + dim(x) <- NULL } x diff --git a/R/ta_HT_SINE.R b/R/ta_HT_SINE.R index 7de5d1d6..c0f4df3d 100644 --- a/R/ta_HT_SINE.R +++ b/R/ta_HT_SINE.R @@ -113,6 +113,34 @@ sine_wave.matrix <- function( ) } +#' @usage NULL +HT_SINE_lookback <- sine_wave_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~close, + data = x, + ... + ) + + .Call( + C_impl_ta_HT_SINE_lookback, + ## splice:lookback:start + constructed_series[[1]] + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases sine_wave @@ -143,7 +171,7 @@ sine_wave.numeric <- function( ) if (dim(x)[2] == 1L) { - x <- as.double(x) + dim(x) <- NULL } x diff --git a/R/ta_HT_TRENDLINE.R b/R/ta_HT_TRENDLINE.R index 3ffbe7b8..ffe15f91 100644 --- a/R/ta_HT_TRENDLINE.R +++ b/R/ta_HT_TRENDLINE.R @@ -113,6 +113,34 @@ trendline.matrix <- function( ) } +#' @usage NULL +HT_TRENDLINE_lookback <- trendline_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~close, + data = x, + ... + ) + + .Call( + C_impl_ta_HT_TRENDLINE_lookback, + ## splice:lookback:start + constructed_series[[1]] + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases trendline @@ -143,7 +171,7 @@ trendline.numeric <- function( ) if (dim(x)[2] == 1L) { - x <- as.double(x) + dim(x) <- NULL } x diff --git a/R/ta_HT_TRENDMODE.R b/R/ta_HT_TRENDMODE.R index a3d0fc48..3369c174 100644 --- a/R/ta_HT_TRENDMODE.R +++ b/R/ta_HT_TRENDMODE.R @@ -113,6 +113,34 @@ trend_cycle_mode.matrix <- function( ) } +#' @usage NULL +HT_TRENDMODE_lookback <- trend_cycle_mode_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~close, + data = x, + ... + ) + + .Call( + C_impl_ta_HT_TRENDMODE_lookback, + ## splice:lookback:start + constructed_series[[1]] + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases trend_cycle_mode @@ -143,7 +171,7 @@ trend_cycle_mode.numeric <- function( ) if (dim(x)[2] == 1L) { - x <- as.double(x) + dim(x) <- NULL } x diff --git a/R/ta_IMI.R b/R/ta_IMI.R index 753987df..74105784 100644 --- a/R/ta_IMI.R +++ b/R/ta_IMI.R @@ -121,6 +121,37 @@ intraday_movement_index.matrix <- function( ) } +#' @usage NULL +IMI_lookback <- intraday_movement_index_lookback <- function( + x, + cols, + n = 14, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ open + close, + data = x, + ... + ) + + .Call( + C_impl_ta_IMI_lookback, + ## splice:lookback:start + constructed_series[[1]], + constructed_series[[2]], + as.integer(n) + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases intraday_movement_index diff --git a/R/ta_KAMA.R b/R/ta_KAMA.R index 2e02e82f..89af3fc3 100644 --- a/R/ta_KAMA.R +++ b/R/ta_KAMA.R @@ -164,12 +164,43 @@ kaufman_adaptive_moving_average.numeric <- function( ) if (dim(x)[2] == 1L) { - x <- as.double(x) + dim(x) <- NULL } x } +#' @usage NULL +KAMA_lookback <- kaufman_adaptive_moving_average_lookback <- function( + x, + cols, + n = 30, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~close, + data = x, + ... + ) + + .Call( + C_impl_ta_KAMA_lookback, + ## splice:lookback:start + as.double(constructed_series[[1]]), + as.integer(n) + ## splice:lookback:end + ) +} + #' @usage NULL #' @aliases kaufman_adaptive_moving_average #' diff --git a/R/ta_MACD.R b/R/ta_MACD.R index 5e900a28..d580e648 100644 --- a/R/ta_MACD.R +++ b/R/ta_MACD.R @@ -137,6 +137,40 @@ moving_average_convergence_divergence.matrix <- function( ) } +#' @usage NULL +MACD_lookback <- moving_average_convergence_divergence_lookback <- function( + x, + cols, + fast = 12, + slow = 26, + signal = 9, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~close, + data = x, + ... + ) + + .Call( + C_impl_ta_MACD_lookback, + ## splice:lookback:start + constructed_series[[1]], + as.integer(fast), + as.integer(slow), + as.integer(signal) + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases moving_average_convergence_divergence @@ -173,7 +207,7 @@ moving_average_convergence_divergence.numeric <- function( ) if (dim(x)[2] == 1L) { - x <- as.double(x) + dim(x) <- NULL } x diff --git a/R/ta_MACDEXT.R b/R/ta_MACDEXT.R index 5b9b4f7b..6c5fa34f 100644 --- a/R/ta_MACDEXT.R +++ b/R/ta_MACDEXT.R @@ -140,6 +140,43 @@ extended_moving_average_convergence_divergence.matrix <- function( ) } +#' @usage NULL +MACDEXT_lookback <- extended_moving_average_convergence_divergence_lookback <- function( + x, + cols, + fast = SMA(n = 12), + slow = SMA(n = 26), + signal = SMA(n = 9), + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~close, + data = x, + ... + ) + + .Call( + C_impl_ta_MACDEXT_lookback, + ## splice:lookback:start + constructed_series[[1]], + fast$n, + fast$maType, + slow$n, + slow$maType, + signal$n, + signal$maType + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases extended_moving_average_convergence_divergence @@ -179,7 +216,7 @@ extended_moving_average_convergence_divergence.numeric <- function( ) if (dim(x)[2] == 1L) { - x <- as.double(x) + dim(x) <- NULL } x diff --git a/R/ta_MACDFIX.R b/R/ta_MACDFIX.R index 9bf9dd6d..2585baee 100644 --- a/R/ta_MACDFIX.R +++ b/R/ta_MACDFIX.R @@ -121,6 +121,36 @@ fixed_moving_average_convergence_divergence.matrix <- function( ) } +#' @usage NULL +MACDFIX_lookback <- fixed_moving_average_convergence_divergence_lookback <- function( + x, + cols, + signal = 9, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~close, + data = x, + ... + ) + + .Call( + C_impl_ta_MACDFIX_lookback, + ## splice:lookback:start + constructed_series[[1]], + as.integer(signal) + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases fixed_moving_average_convergence_divergence @@ -153,7 +183,7 @@ fixed_moving_average_convergence_divergence.numeric <- function( ) if (dim(x)[2] == 1L) { - x <- as.double(x) + dim(x) <- NULL } x diff --git a/R/ta_MAMA.R b/R/ta_MAMA.R index 863fe8f5..f13d758f 100644 --- a/R/ta_MAMA.R +++ b/R/ta_MAMA.R @@ -183,12 +183,46 @@ mesa_adaptive_moving_average.numeric <- function( ) if (dim(x)[2] == 1L) { - x <- as.double(x) + dim(x) <- NULL } x } +#' @usage NULL +MAMA_lookback <- mesa_adaptive_moving_average_lookback <- function( + x, + cols, + n = 30, + fast = 0.5, + slow = 0.05, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~close, + data = x, + ... + ) + + .Call( + C_impl_ta_MAMA_lookback, + ## splice:lookback:start + as.double(constructed_series[[1]]), + as.double(fast), + as.double(slow) + ## splice:lookback:end + ) +} + #' @usage NULL #' @aliases mesa_adaptive_moving_average #' diff --git a/R/ta_MAX.R b/R/ta_MAX.R index 4f65c529..f8f6d409 100644 --- a/R/ta_MAX.R +++ b/R/ta_MAX.R @@ -46,8 +46,13 @@ rolling_max.default <- function( as.logical(na.bridge) ) + ## strip dimensions + ## while preserving + ## attributes + dim(x) <- NULL + ## return indicator - as.double(x) + x } #' @usage NULL @@ -67,6 +72,25 @@ rolling_max.numeric <- function( na.bridge = na.bridge ) + ## strip dimensions + ## while preserving + ## attributes + dim(x) <- NULL + ## return indicator - as.double(x) + x +} + +#' @usage NULL +MAX_lookback <- rolling_max_lookback <- function( + x, + n = 30 +) { + .Call( + C_impl_ta_MAX_lookback, + ## splice:lookback:start + as.double(x), + as.integer(n) + ## splice:lookback:end + ) } diff --git a/R/ta_MEDPRICE.R b/R/ta_MEDPRICE.R index d3dbb04d..4535323e 100644 --- a/R/ta_MEDPRICE.R +++ b/R/ta_MEDPRICE.R @@ -113,3 +113,33 @@ median_price.matrix <- function( ... ) } + +#' @usage NULL +MEDPRICE_lookback <- median_price_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ high + low, + data = x, + ... + ) + + .Call( + C_impl_ta_MEDPRICE_lookback, + ## splice:lookback:start + constructed_series[[1]], + constructed_series[[2]] + ## splice:lookback:end + ) +} diff --git a/R/ta_MFI.R b/R/ta_MFI.R index 7849841d..0f6ef5d3 100644 --- a/R/ta_MFI.R +++ b/R/ta_MFI.R @@ -123,6 +123,39 @@ money_flow_index.matrix <- function( ) } +#' @usage NULL +MFI_lookback <- money_flow_index_lookback <- function( + x, + cols, + n = 14, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ high + low + close + volume, + data = x, + ... + ) + + .Call( + C_impl_ta_MFI_lookback, + ## splice:lookback:start + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]], + as.integer(n) + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases money_flow_index diff --git a/R/ta_MIDPRICE.R b/R/ta_MIDPRICE.R index ef6a798f..05f071ed 100644 --- a/R/ta_MIDPRICE.R +++ b/R/ta_MIDPRICE.R @@ -120,3 +120,35 @@ midpoint_price.matrix <- function( ... ) } + +#' @usage NULL +MIDPRICE_lookback <- midpoint_price_lookback <- function( + x, + cols, + n = 14, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ high + low, + data = x, + ... + ) + + .Call( + C_impl_ta_MIDPRICE_lookback, + ## splice:lookback:start + constructed_series[[1]], + constructed_series[[2]], + as.integer(n) + ## splice:lookback:end + ) +} diff --git a/R/ta_MIN.R b/R/ta_MIN.R index d9535346..50e8693b 100644 --- a/R/ta_MIN.R +++ b/R/ta_MIN.R @@ -46,8 +46,13 @@ rolling_min.default <- function( as.logical(na.bridge) ) + ## strip dimensions + ## while preserving + ## attributes + dim(x) <- NULL + ## return indicator - as.double(x) + x } #' @usage NULL @@ -67,6 +72,25 @@ rolling_min.numeric <- function( na.bridge = na.bridge ) + ## strip dimensions + ## while preserving + ## attributes + dim(x) <- NULL + ## return indicator - as.double(x) + x +} + +#' @usage NULL +MIN_lookback <- rolling_min_lookback <- function( + x, + n = 30 +) { + .Call( + C_impl_ta_MIN_lookback, + ## splice:lookback:start + as.double(x), + as.integer(n) + ## splice:lookback:end + ) } diff --git a/R/ta_MINUS_DI.R b/R/ta_MINUS_DI.R index 22dcea0d..dd54051d 100644 --- a/R/ta_MINUS_DI.R +++ b/R/ta_MINUS_DI.R @@ -122,6 +122,38 @@ minus_directional_indicator.matrix <- function( ) } +#' @usage NULL +MINUS_DI_lookback <- minus_directional_indicator_lookback <- function( + x, + cols, + n = 14, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_MINUS_DI_lookback, + ## splice:lookback:start + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + as.integer(n) + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases minus_directional_indicator diff --git a/R/ta_MINUS_DM.R b/R/ta_MINUS_DM.R index c46367ee..e0271791 100644 --- a/R/ta_MINUS_DM.R +++ b/R/ta_MINUS_DM.R @@ -121,6 +121,37 @@ minus_directional_movement.matrix <- function( ) } +#' @usage NULL +MINUS_DM_lookback <- minus_directional_movement_lookback <- function( + x, + cols, + n = 14, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ high + low, + data = x, + ... + ) + + .Call( + C_impl_ta_MINUS_DM_lookback, + ## splice:lookback:start + constructed_series[[1]], + constructed_series[[2]], + as.integer(n) + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases minus_directional_movement diff --git a/R/ta_MOM.R b/R/ta_MOM.R index e0d93908..71a72cb7 100644 --- a/R/ta_MOM.R +++ b/R/ta_MOM.R @@ -120,6 +120,36 @@ momentum.matrix <- function( ) } +#' @usage NULL +MOM_lookback <- momentum_lookback <- function( + x, + cols, + n = 10, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~close, + data = x, + ... + ) + + .Call( + C_impl_ta_MOM_lookback, + ## splice:lookback:start + constructed_series[[1]], + as.integer(n) + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases momentum @@ -152,7 +182,7 @@ momentum.numeric <- function( ) if (dim(x)[2] == 1L) { - x <- as.double(x) + dim(x) <- NULL } x diff --git a/R/ta_NATR.R b/R/ta_NATR.R index aaa630e4..b4f33977 100644 --- a/R/ta_NATR.R +++ b/R/ta_NATR.R @@ -122,6 +122,38 @@ normalized_average_true_range.matrix <- function( ) } +#' @usage NULL +NATR_lookback <- normalized_average_true_range_lookback <- function( + x, + cols, + n = 14, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_NATR_lookback, + ## splice:lookback:start + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + as.integer(n) + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases normalized_average_true_range diff --git a/R/ta_OBV.R b/R/ta_OBV.R index 829fb336..0d9b4c0c 100644 --- a/R/ta_OBV.R +++ b/R/ta_OBV.R @@ -114,6 +114,35 @@ on_balance_volume.matrix <- function( ) } +#' @usage NULL +OBV_lookback <- on_balance_volume_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ close + volume, + data = x, + ... + ) + + .Call( + C_impl_ta_OBV_lookback, + ## splice:lookback:start + constructed_series[[1]], + constructed_series[[2]] + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases on_balance_volume diff --git a/R/ta_PLUS_DI.R b/R/ta_PLUS_DI.R index 98563a50..3e902274 100644 --- a/R/ta_PLUS_DI.R +++ b/R/ta_PLUS_DI.R @@ -122,6 +122,38 @@ plus_directional_indicator.matrix <- function( ) } +#' @usage NULL +PLUS_DI_lookback <- plus_directional_indicator_lookback <- function( + x, + cols, + n = 14, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_PLUS_DI_lookback, + ## splice:lookback:start + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + as.integer(n) + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases plus_directional_indicator diff --git a/R/ta_PLUS_DM.R b/R/ta_PLUS_DM.R index b24dd5c7..8f1615dc 100644 --- a/R/ta_PLUS_DM.R +++ b/R/ta_PLUS_DM.R @@ -121,6 +121,37 @@ plus_directional_movement.matrix <- function( ) } +#' @usage NULL +PLUS_DM_lookback <- plus_directional_movement_lookback <- function( + x, + cols, + n = 14, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ high + low, + data = x, + ... + ) + + .Call( + C_impl_ta_PLUS_DM_lookback, + ## splice:lookback:start + constructed_series[[1]], + constructed_series[[2]], + as.integer(n) + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases plus_directional_movement diff --git a/R/ta_PPO.R b/R/ta_PPO.R index 509b2efc..ef11b663 100644 --- a/R/ta_PPO.R +++ b/R/ta_PPO.R @@ -137,6 +137,40 @@ percentage_price_oscillator.matrix <- function( ) } +#' @usage NULL +PPO_lookback <- percentage_price_oscillator_lookback <- function( + x, + cols, + fast = 12, + slow = 26, + ma = SMA(n = 9), + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~close, + data = x, + ... + ) + + .Call( + C_impl_ta_PPO_lookback, + ## splice:lookback:start + constructed_series[[1]], + as.integer(fast), + as.integer(slow), + ma$maType + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases percentage_price_oscillator @@ -173,7 +207,7 @@ percentage_price_oscillator.numeric <- function( ) if (dim(x)[2] == 1L) { - x <- as.double(x) + dim(x) <- NULL } x diff --git a/R/ta_ROC.R b/R/ta_ROC.R index 554e9496..c050d546 100644 --- a/R/ta_ROC.R +++ b/R/ta_ROC.R @@ -120,6 +120,36 @@ rate_of_change.matrix <- function( ) } +#' @usage NULL +ROC_lookback <- rate_of_change_lookback <- function( + x, + cols, + n = 10, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~close, + data = x, + ... + ) + + .Call( + C_impl_ta_ROC_lookback, + ## splice:lookback:start + constructed_series[[1]], + as.integer(n) + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases rate_of_change @@ -152,7 +182,7 @@ rate_of_change.numeric <- function( ) if (dim(x)[2] == 1L) { - x <- as.double(x) + dim(x) <- NULL } x diff --git a/R/ta_ROCR.R b/R/ta_ROCR.R index 64adfaad..476f46f5 100644 --- a/R/ta_ROCR.R +++ b/R/ta_ROCR.R @@ -120,6 +120,36 @@ ratio_of_change.matrix <- function( ) } +#' @usage NULL +ROCR_lookback <- ratio_of_change_lookback <- function( + x, + cols, + n = 10, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~close, + data = x, + ... + ) + + .Call( + C_impl_ta_ROCR_lookback, + ## splice:lookback:start + constructed_series[[1]], + as.integer(n) + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases ratio_of_change @@ -152,7 +182,7 @@ ratio_of_change.numeric <- function( ) if (dim(x)[2] == 1L) { - x <- as.double(x) + dim(x) <- NULL } x diff --git a/R/ta_RSI.R b/R/ta_RSI.R index 1d0263df..b1bec585 100644 --- a/R/ta_RSI.R +++ b/R/ta_RSI.R @@ -120,6 +120,36 @@ relative_strength_index.matrix <- function( ) } +#' @usage NULL +RSI_lookback <- relative_strength_index_lookback <- function( + x, + cols, + n = 14, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~close, + data = x, + ... + ) + + .Call( + C_impl_ta_RSI_lookback, + ## splice:lookback:start + constructed_series[[1]], + as.integer(n) + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases relative_strength_index @@ -152,7 +182,7 @@ relative_strength_index.numeric <- function( ) if (dim(x)[2] == 1L) { - x <- as.double(x) + dim(x) <- NULL } x diff --git a/R/ta_SAR.R b/R/ta_SAR.R index 94891527..8698e7a6 100644 --- a/R/ta_SAR.R +++ b/R/ta_SAR.R @@ -130,6 +130,39 @@ parabolic_stop_and_reverse.matrix <- function( ) } +#' @usage NULL +SAR_lookback <- parabolic_stop_and_reverse_lookback <- function( + x, + cols, + acceleration = 0.02, + maximum = 0.2, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ high + low, + data = x, + ... + ) + + .Call( + C_impl_ta_SAR_lookback, + ## splice:lookback:start + constructed_series[[1]], + constructed_series[[2]], + as.double(acceleration), + as.double(maximum) + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases parabolic_stop_and_reverse diff --git a/R/ta_SAREXT.R b/R/ta_SAREXT.R index 36b24f64..8229f3c7 100644 --- a/R/ta_SAREXT.R +++ b/R/ta_SAREXT.R @@ -178,6 +178,51 @@ extended_parabolic_stop_and_reverse.matrix <- function( ) } +#' @usage NULL +SAREXT_lookback <- extended_parabolic_stop_and_reverse_lookback <- function( + x, + cols, + init = 0, + offset = 0, + init_long = 0.02, + long = 0.02, + max_long = 0.2, + init_short = 0.02, + short = 0.02, + max_short = 0.2, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ high + low, + data = x, + ... + ) + + .Call( + C_impl_ta_SAREXT_lookback, + ## splice:lookback:start + constructed_series[[1]], + constructed_series[[2]], + init, + offset, + init_long, + long, + max_long, + init_short, + short, + max_short + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases extended_parabolic_stop_and_reverse diff --git a/R/ta_SMA.R b/R/ta_SMA.R index 79c660f1..ce9400d9 100644 --- a/R/ta_SMA.R +++ b/R/ta_SMA.R @@ -164,12 +164,43 @@ simple_moving_average.numeric <- function( ) if (dim(x)[2] == 1L) { - x <- as.double(x) + dim(x) <- NULL } x } +#' @usage NULL +SMA_lookback <- simple_moving_average_lookback <- function( + x, + cols, + n = 30, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~close, + data = x, + ... + ) + + .Call( + C_impl_ta_SMA_lookback, + ## splice:lookback:start + as.double(constructed_series[[1]]), + as.integer(n) + ## splice:lookback:end + ) +} + #' @usage NULL #' @aliases simple_moving_average #' diff --git a/R/ta_STDDEV.R b/R/ta_STDDEV.R index 4bc21d5a..21ae6b9a 100644 --- a/R/ta_STDDEV.R +++ b/R/ta_STDDEV.R @@ -50,8 +50,13 @@ rolling_standard_deviation.default <- function( as.logical(na.bridge) ) + ## strip dimensions + ## while preserving + ## attributes + dim(x) <- NULL + ## return indicator - as.double(x) + x } #' @usage NULL @@ -73,6 +78,27 @@ rolling_standard_deviation.numeric <- function( na.bridge = na.bridge ) + ## strip dimensions + ## while preserving + ## attributes + dim(x) <- NULL + ## return indicator - as.double(x) + x +} + +#' @usage NULL +STDDEV_lookback <- rolling_standard_deviation_lookback <- function( + x, + n = 5, + k = 1 +) { + .Call( + C_impl_ta_STDDEV_lookback, + ## splice:lookback:start + as.double(x), + as.integer(n), + as.double(k) + ## splice:lookback:end + ) } diff --git a/R/ta_STOCH.R b/R/ta_STOCH.R index 735c6aa5..c1598bee 100644 --- a/R/ta_STOCH.R +++ b/R/ta_STOCH.R @@ -141,6 +141,44 @@ stochastic.matrix <- function( ) } +#' @usage NULL +STOCH_lookback <- stochastic_lookback <- function( + x, + cols, + fastk = 5, + slowk = SMA(n = 3), + slowd = SMA(n = 3), + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_STOCH_lookback, + ## splice:lookback:start + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + as.integer(fastk), + as.integer(slowk$n), + as.integer(slowk$maType), + as.integer(slowd$n), + as.integer(slowd$maType) + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases stochastic diff --git a/R/ta_STOCHF.R b/R/ta_STOCHF.R index 77fe43ad..28939fc2 100644 --- a/R/ta_STOCHF.R +++ b/R/ta_STOCHF.R @@ -132,6 +132,41 @@ fast_stochastic.matrix <- function( ) } +#' @usage NULL +STOCHF_lookback <- fast_stochastic_lookback <- function( + x, + cols, + fastk = 5, + fastd = SMA(n = 3), + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_STOCHF_lookback, + ## splice:lookback:start + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + as.integer(fastk), + as.integer(fastd$n), + as.integer(fastd$maType) + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases fast_stochastic diff --git a/R/ta_STOCHRSI.R b/R/ta_STOCHRSI.R index 8573ca9b..04c9fe20 100644 --- a/R/ta_STOCHRSI.R +++ b/R/ta_STOCHRSI.R @@ -137,6 +137,41 @@ stochastic_relative_strength_index.matrix <- function( ) } +#' @usage NULL +STOCHRSI_lookback <- stochastic_relative_strength_index_lookback <- function( + x, + cols, + n = 14, + fastk = 5, + fastd = SMA(n = 3), + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~close, + data = x, + ... + ) + + .Call( + C_impl_ta_STOCHRSI_lookback, + ## splice:lookback:start + constructed_series[[1]], + as.integer(n), + as.integer(fastk), + as.integer(fastd$n), + as.integer(fastd$maType) + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases stochastic_relative_strength_index @@ -174,7 +209,7 @@ stochastic_relative_strength_index.numeric <- function( ) if (dim(x)[2] == 1L) { - x <- as.double(x) + dim(x) <- NULL } x diff --git a/R/ta_SUM.R b/R/ta_SUM.R index 7cdf8cef..f8fc6020 100644 --- a/R/ta_SUM.R +++ b/R/ta_SUM.R @@ -46,8 +46,13 @@ rolling_sum.default <- function( as.logical(na.bridge) ) + ## strip dimensions + ## while preserving + ## attributes + dim(x) <- NULL + ## return indicator - as.double(x) + x } #' @usage NULL @@ -67,6 +72,25 @@ rolling_sum.numeric <- function( na.bridge = na.bridge ) + ## strip dimensions + ## while preserving + ## attributes + dim(x) <- NULL + ## return indicator - as.double(x) + x +} + +#' @usage NULL +SUM_lookback <- rolling_sum_lookback <- function( + x, + n = 30 +) { + .Call( + C_impl_ta_SUM_lookback, + ## splice:lookback:start + as.double(x), + as.integer(n) + ## splice:lookback:end + ) } diff --git a/R/ta_T3.R b/R/ta_T3.R index 933356d9..5d3d00bf 100644 --- a/R/ta_T3.R +++ b/R/ta_T3.R @@ -174,12 +174,45 @@ t3_exponential_moving_average.numeric <- function( ) if (dim(x)[2] == 1L) { - x <- as.double(x) + dim(x) <- NULL } x } +#' @usage NULL +T3_lookback <- t3_exponential_moving_average_lookback <- function( + x, + cols, + n = 5, + vfactor = 0.7, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~close, + data = x, + ... + ) + + .Call( + C_impl_ta_T3_lookback, + ## splice:lookback:start + as.double(constructed_series[[1]]), + as.integer(n), + as.double(vfactor) + ## splice:lookback:end + ) +} + #' @usage NULL #' @aliases t3_exponential_moving_average #' diff --git a/R/ta_TEMA.R b/R/ta_TEMA.R index 98857cbc..ec7832ff 100644 --- a/R/ta_TEMA.R +++ b/R/ta_TEMA.R @@ -164,12 +164,43 @@ triple_exponential_moving_average.numeric <- function( ) if (dim(x)[2] == 1L) { - x <- as.double(x) + dim(x) <- NULL } x } +#' @usage NULL +TEMA_lookback <- triple_exponential_moving_average_lookback <- function( + x, + cols, + n = 30, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~close, + data = x, + ... + ) + + .Call( + C_impl_ta_TEMA_lookback, + ## splice:lookback:start + as.double(constructed_series[[1]]), + as.integer(n) + ## splice:lookback:end + ) +} + #' @usage NULL #' @aliases triple_exponential_moving_average #' diff --git a/R/ta_TRANGE.R b/R/ta_TRANGE.R index 943ca796..54985832 100644 --- a/R/ta_TRANGE.R +++ b/R/ta_TRANGE.R @@ -115,6 +115,36 @@ true_range.matrix <- function( ) } +#' @usage NULL +TRANGE_lookback <- true_range_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_TRANGE_lookback, + ## splice:lookback:start + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]] + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases true_range diff --git a/R/ta_TRIMA.R b/R/ta_TRIMA.R index a63af257..1884c1a4 100644 --- a/R/ta_TRIMA.R +++ b/R/ta_TRIMA.R @@ -164,12 +164,43 @@ triangular_moving_average.numeric <- function( ) if (dim(x)[2] == 1L) { - x <- as.double(x) + dim(x) <- NULL } x } +#' @usage NULL +TRIMA_lookback <- triangular_moving_average_lookback <- function( + x, + cols, + n = 30, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~close, + data = x, + ... + ) + + .Call( + C_impl_ta_TRIMA_lookback, + ## splice:lookback:start + as.double(constructed_series[[1]]), + as.integer(n) + ## splice:lookback:end + ) +} + #' @usage NULL #' @aliases triangular_moving_average #' diff --git a/R/ta_TRIX.R b/R/ta_TRIX.R index e4b64072..c019ef9a 100644 --- a/R/ta_TRIX.R +++ b/R/ta_TRIX.R @@ -120,6 +120,36 @@ triple_exponential_average.matrix <- function( ) } +#' @usage NULL +TRIX_lookback <- triple_exponential_average_lookback <- function( + x, + cols, + n = 30, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~close, + data = x, + ... + ) + + .Call( + C_impl_ta_TRIX_lookback, + ## splice:lookback:start + constructed_series[[1]], + as.integer(n) + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases triple_exponential_average @@ -152,7 +182,7 @@ triple_exponential_average.numeric <- function( ) if (dim(x)[2] == 1L) { - x <- as.double(x) + dim(x) <- NULL } x diff --git a/R/ta_TYPPRICE.R b/R/ta_TYPPRICE.R index a1628d57..ef6b1f07 100644 --- a/R/ta_TYPPRICE.R +++ b/R/ta_TYPPRICE.R @@ -114,3 +114,34 @@ typical_price.matrix <- function( ... ) } + +#' @usage NULL +TYPPRICE_lookback <- typical_price_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_TYPPRICE_lookback, + ## splice:lookback:start + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]] + ## splice:lookback:end + ) +} diff --git a/R/ta_ULTOSC.R b/R/ta_ULTOSC.R index b9792b5b..5a41dc97 100644 --- a/R/ta_ULTOSC.R +++ b/R/ta_ULTOSC.R @@ -124,6 +124,40 @@ ultimate_oscillator.matrix <- function( ) } +#' @usage NULL +ULTOSC_lookback <- ultimate_oscillator_lookback <- function( + x, + cols, + n = c(7, 14, 28), + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_ULTOSC_lookback, + ## splice:lookback:start + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + as.integer(n[1]), + as.integer(n[2]), + as.integer(n[3]) + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases ultimate_oscillator diff --git a/R/ta_VAR.R b/R/ta_VAR.R index 092542f1..4b6e9a01 100644 --- a/R/ta_VAR.R +++ b/R/ta_VAR.R @@ -50,8 +50,13 @@ rolling_variance.default <- function( as.logical(na.bridge) ) + ## strip dimensions + ## while preserving + ## attributes + dim(x) <- NULL + ## return indicator - as.double(x) + x } #' @usage NULL @@ -73,6 +78,27 @@ rolling_variance.numeric <- function( na.bridge = na.bridge ) + ## strip dimensions + ## while preserving + ## attributes + dim(x) <- NULL + ## return indicator - as.double(x) + x +} + +#' @usage NULL +VAR_lookback <- rolling_variance_lookback <- function( + x, + n = 5, + k = 1 +) { + .Call( + C_impl_ta_VAR_lookback, + ## splice:lookback:start + as.double(x), + as.integer(n), + as.double(k) + ## splice:lookback:end + ) } diff --git a/R/ta_VOLUME.R b/R/ta_VOLUME.R index f60c636d..e2319d8b 100644 --- a/R/ta_VOLUME.R +++ b/R/ta_VOLUME.R @@ -128,6 +128,43 @@ trading_volume.matrix <- function( ) } +#' @usage NULL +VOLUME_lookback <- trading_volume_lookback <- function( + x, + cols, + ma = list(SMA(n = 7), SMA(n = 15)), + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ volume + open + close, + data = x, + ... + ) + + .Call( + C_impl_ta_VOLUME_lookback, + ## splice:lookback:start + as.double(constructed_series[[1]]), + lapply( + ma, + function(x) { + as.integer( + unlist(x, use.names = FALSE) + ) + } + ) + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases trading_volume @@ -160,7 +197,7 @@ trading_volume.numeric <- function( ) if (dim(x)[2] == 1L) { - x <- as.double(x) + dim(x) <- NULL } x diff --git a/R/ta_WCLPRICE.R b/R/ta_WCLPRICE.R index f0e20bbf..b4940943 100644 --- a/R/ta_WCLPRICE.R +++ b/R/ta_WCLPRICE.R @@ -114,3 +114,34 @@ weighted_close_price.matrix <- function( ... ) } + +#' @usage NULL +WCLPRICE_lookback <- weighted_close_price_lookback <- function( + x, + cols, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_WCLPRICE_lookback, + ## splice:lookback:start + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]] + ## splice:lookback:end + ) +} diff --git a/R/ta_WILLR.R b/R/ta_WILLR.R index 21c0a78d..2f48ea2a 100644 --- a/R/ta_WILLR.R +++ b/R/ta_WILLR.R @@ -122,6 +122,38 @@ williams_oscillator.matrix <- function( ) } +#' @usage NULL +WILLR_lookback <- williams_oscillator_lookback <- function( + x, + cols, + n = 14, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~ high + low + close, + data = x, + ... + ) + + .Call( + C_impl_ta_WILLR_lookback, + ## splice:lookback:start + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + as.integer(n) + ## splice:lookback:end + ) +} #' @usage NULL #' @aliases williams_oscillator diff --git a/R/ta_WMA.R b/R/ta_WMA.R index 7053c48e..917817d2 100644 --- a/R/ta_WMA.R +++ b/R/ta_WMA.R @@ -164,12 +164,43 @@ weighted_moving_average.numeric <- function( ) if (dim(x)[2] == 1L) { - x <- as.double(x) + dim(x) <- NULL } x } +#' @usage NULL +WMA_lookback <- weighted_moving_average_lookback <- function( + x, + cols, + n = 30, + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ~close, + data = x, + ... + ) + + .Call( + C_impl_ta_WMA_lookback, + ## splice:lookback:start + as.double(constructed_series[[1]]), + as.integer(n) + ## splice:lookback:end + ) +} + #' @usage NULL #' @aliases weighted_moving_average #' diff --git a/_pkgdown.yml b/_pkgdown.yml index b2ac7948..9725b704 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -76,6 +76,11 @@ reference: Transform raw OHLC prices into derived series. Average Price, Median Price, Typical Price, and Weighted Close Price. - contents: has_concept('Price Transform') +- title: Utility Functions + desc: > + Utility functions used for downstream packages and wrappers that + improves and simplifies the control-flow. +- contents: has_concept('Utility') - title: Financial Data desc: > Built-in OHLCV datasets for examples, testing, and exploration. diff --git a/codegen/generate_indicator_core.sh b/codegen/generate_indicator_core.sh index 56d2e5d8..b0141d3a 100755 --- a/codegen/generate_indicator_core.sh +++ b/codegen/generate_indicator_core.sh @@ -144,7 +144,7 @@ done for i in "${!in_scalars_name[@]}"; do R_SIGNATURE+=$'\tSEXP '"${in_scalars_name[$i]}"$',\n' done -R_SIGNATURE=${R_SIGNATURE%$'\n'} +R_SIGNATURE=${R_SIGNATURE%,$'\n'} ## 6) PARAM_DOC ## diff --git a/codegen/generate_unit-tests.sh b/codegen/generate_unit-tests.sh index 685ea702..df2c2803 100755 --- a/codegen/generate_unit-tests.sh +++ b/codegen/generate_unit-tests.sh @@ -70,11 +70,29 @@ testthat::expect_true( ) testthat::expect_true( - is.vector(output) + is.null(dim(output)) ) }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + +output <- attr( + ${FUN}(x = SPY[,1]${ADDITIONAL}), + "lookback" +) + +testthat::expect_equal( + object = output, + expected = lookback(FUN = ${FUN}, x = SPY[,1]${ADDITIONAL}) + ) + +} +) + + EOF exit 0; @@ -232,6 +250,24 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) + +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + +output <- attr( + ${FUN}(SPY), + "lookback" +) + +testthat::expect_equal( + object = output, + expected = lookback(FUN = ${FUN}, x = SPY) + ) + +} +) + EOF ## Add plotly methods diff --git a/codegen/templates/candlestick_template.R.in b/codegen/templates/candlestick_template.R.in index a1d685cb..1f18d98c 100644 --- a/codegen/templates/candlestick_template.R.in +++ b/codegen/templates/candlestick_template.R.in @@ -130,6 +130,36 @@ $FUN.matrix <- function( NextMethod() } +#' @usage NULL +${ALIAS}_lookback <- ${FUN}_lookback <- function( + x, + cols,${ARGS} + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ${FORMULA}, + data = x, + ... + ) + + .Call( + C_impl_ta_${TA_FUN}_lookback, + constructed_series[[1]], + constructed_series[[2]], + constructed_series[[3]], + constructed_series[[4]] ${CARGS} + ) +} + #' @usage NULL #' @aliases $FUN #' diff --git a/codegen/templates/candlestick_template.c.in b/codegen/templates/candlestick_template.c.in index ac9564a0..79e6e6e7 100644 --- a/codegen/templates/candlestick_template.c.in +++ b/codegen/templates/candlestick_template.c.in @@ -24,6 +24,37 @@ #include "normalize.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_${NAME}_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose{{PEN_ARG}} +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + {{PEN_READ}} + + // calculate lookback + const int lookback = {{LOOKBACK}} + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_{{NAME}}( SEXP inOpen, diff --git a/codegen/templates/indicator_template.R.in b/codegen/templates/indicator_template.R.in index 0abd895b..84b84f02 100644 --- a/codegen/templates/indicator_template.R.in +++ b/codegen/templates/indicator_template.R.in @@ -110,3 +110,31 @@ ${FUN}.matrix <- function( ... ) } + +#' @usage NULL +${ALIAS}_lookback <- ${FUN}_lookback <- function( + x, + cols,${ARGS} + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ${FORMULA}, + data = x, + ... + ) + + .Call( + C_impl_ta_${TA_FUN}_lookback, + ## splice:lookback:start + ## splice:lookback:end + ) +} \ No newline at end of file diff --git a/codegen/templates/indicator_template.c.in b/codegen/templates/indicator_template.c.in index c8ade4f0..48d38ab7 100644 --- a/codegen/templates/indicator_template.c.in +++ b/codegen/templates/indicator_template.c.in @@ -20,8 +20,29 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers // clang-format off -SEXP impl_ta_${NAME}($R_SIGNATURE +SEXP impl_ta_${NAME}_lookback($R_SIGNATURE +) +// clang-format on +{ + // values + $VALUES + + // calculate lookback + const int lookback = TA_${NAME}_Lookback($LOOKBACK_ARGS); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + +// clang-format off +SEXP impl_ta_${NAME}($R_SIGNATURE, SEXP na_bridge ) // clang-format on diff --git a/codegen/templates/moving_average_template.R.in b/codegen/templates/moving_average_template.R.in index 228b774a..10ce0dbe 100644 --- a/codegen/templates/moving_average_template.R.in +++ b/codegen/templates/moving_average_template.R.in @@ -156,13 +156,41 @@ $FUN.numeric <- function( ) if (dim(x)[2] == 1L) { - x <- as.double(x) + dim(x) <- NULL } x } +#' @usage NULL +${ALIAS}_lookback <- ${FUN}_lookback <- function( + x, + cols,${ARGS} + ... +) { + ## validate 'cols'-argument + ## if explicitly passed + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series + ## from input + constructed_series <- series( + x = cols, + default_formula = ${FORMULA}, + data = x, + ... + ) + + .Call( + C_impl_ta_${TA_FUN}_lookback, + ## splice:lookback:start + ## splice:lookback:end + ) +} + #' @usage NULL #' @aliases $FUN #' diff --git a/codegen/templates/numeric_template.R.in b/codegen/templates/numeric_template.R.in index 32d89dbf..755b20b2 100644 --- a/codegen/templates/numeric_template.R.in +++ b/codegen/templates/numeric_template.R.in @@ -27,7 +27,7 @@ ${FUN}.numeric <- function( ) if (dim(x)[2] == 1L) { - x <- as.double(x) + dim(x) <- NULL } x diff --git a/codegen/templates/rolling_template.R.in b/codegen/templates/rolling_template.R.in index 5a8a965e..70683b2f 100644 --- a/codegen/templates/rolling_template.R.in +++ b/codegen/templates/rolling_template.R.in @@ -45,8 +45,13 @@ ${FUN}.default <- function( as.logical(na.bridge) ) + ## strip dimensions + ## while preserving + ## attributes + dim(x) <- NULL + ## return indicator - as.double(x) + x } #' @usage NULL @@ -67,6 +72,24 @@ ${FUN}.numeric <- function( ) + ## strip dimensions + ## while preserving + ## attributes + dim(x) <- NULL + ## return indicator - as.double(x) + x +} + +#' @usage NULL +${ALIAS}_lookback <- ${FUN}_lookback <- function( + x,${ARGS} +) { + + .Call( + C_impl_ta_${TA_FUN}_lookback, + ## splice:lookback:start + ## splice:lookback:end + ) + } diff --git a/src/api.h b/src/api.h index a119d943..b8847560 100644 --- a/src/api.h +++ b/src/api.h @@ -5,133 +5,261 @@ #include // clang-format off +SEXP impl_ta_ACCBANDS_lookback(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod); SEXP impl_ta_ACCBANDS(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod, SEXP na_bridge); +SEXP impl_ta_AD_lookback(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP inVolume); +SEXP impl_ta_ADOSC_lookback(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP inVolume, SEXP optInFastPeriod, SEXP optInSlowPeriod); SEXP impl_ta_ADOSC(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP inVolume, SEXP optInFastPeriod, SEXP optInSlowPeriod, SEXP na_bridge); SEXP impl_ta_AD(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP inVolume, SEXP na_bridge); +SEXP impl_ta_ADX_lookback(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod); +SEXP impl_ta_ADXR_lookback(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod); SEXP impl_ta_ADXR(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod, SEXP na_bridge); SEXP impl_ta_ADX(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod, SEXP na_bridge); +SEXP impl_ta_APO_lookback(SEXP inReal, SEXP optInFastPeriod, SEXP optInSlowPeriod, SEXP optInMAType); SEXP impl_ta_APO(SEXP inReal, SEXP optInFastPeriod, SEXP optInSlowPeriod, SEXP optInMAType, SEXP na_bridge); +SEXP impl_ta_AROON_lookback(SEXP inHigh, SEXP inLow, SEXP optInTimePeriod); +SEXP impl_ta_AROONOSC_lookback(SEXP inHigh, SEXP inLow, SEXP optInTimePeriod); SEXP impl_ta_AROONOSC(SEXP inHigh, SEXP inLow, SEXP optInTimePeriod, SEXP na_bridge); SEXP impl_ta_AROON(SEXP inHigh, SEXP inLow, SEXP optInTimePeriod, SEXP na_bridge); +SEXP impl_ta_ATR_lookback(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod); SEXP impl_ta_ATR(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod, SEXP na_bridge); +SEXP impl_ta_AVGPRICE_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_AVGPRICE(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP na_bridge); +SEXP impl_ta_BBANDS_lookback(SEXP inReal, SEXP optInTimePeriod, SEXP optInNbDevUp, SEXP optInNbDevDn, SEXP optInMAType); SEXP impl_ta_BBANDS(SEXP inReal, SEXP optInTimePeriod, SEXP optInNbDevUp, SEXP optInNbDevDn, SEXP optInMAType, SEXP na_bridge); +SEXP impl_ta_BETA_lookback(SEXP inReal0, SEXP inReal1, SEXP optInTimePeriod); SEXP impl_ta_BETA(SEXP inReal0, SEXP inReal1, SEXP optInTimePeriod, SEXP na_bridge); +SEXP impl_ta_BOP_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_BOP(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP na_bridge); +SEXP impl_ta_CCI_lookback(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod); SEXP impl_ta_CCI(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod, SEXP na_bridge); +SEXP impl_ta_CDL2CROWS_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDL2CROWS(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDL3BLACKCROWS_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDL3BLACKCROWS(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDL3INSIDE_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDL3INSIDE(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDL3LINESTRIKE_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDL3LINESTRIKE(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDL3OUTSIDE_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDL3OUTSIDE(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDL3STARSINSOUTH_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDL3STARSINSOUTH(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDL3WHITESOLDIERS_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDL3WHITESOLDIERS(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLABANDONEDBABY_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInPenetration); SEXP impl_ta_CDLABANDONEDBABY(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInPenetration, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLADVANCEBLOCK_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLADVANCEBLOCK(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLBELTHOLD_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLBELTHOLD(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLBREAKAWAY_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLBREAKAWAY(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLCLOSINGMARUBOZU_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLCLOSINGMARUBOZU(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLCONCEALBABYSWALL_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLCONCEALBABYSWALL(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLCOUNTERATTACK_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLCOUNTERATTACK(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLDARKCLOUDCOVER_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInPenetration); SEXP impl_ta_CDLDARKCLOUDCOVER(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInPenetration, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLDOJI_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLDOJI(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLDOJISTAR_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLDOJISTAR(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLDRAGONFLYDOJI_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLDRAGONFLYDOJI(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLENGULFING_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLENGULFING(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLEVENINGDOJISTAR_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInPenetration); SEXP impl_ta_CDLEVENINGDOJISTAR(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInPenetration, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLEVENINGSTAR_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInPenetration); SEXP impl_ta_CDLEVENINGSTAR(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInPenetration, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLGAPSIDESIDEWHITE_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLGAPSIDESIDEWHITE(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLGRAVESTONEDOJI_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLGRAVESTONEDOJI(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLHAMMER_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLHAMMER(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLHANGINGMAN_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLHANGINGMAN(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLHARAMICROSS_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLHARAMICROSS(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLHARAMI_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLHARAMI(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLHIGHWAVE_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLHIGHWAVE(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLHIKKAKE_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); +SEXP impl_ta_CDLHIKKAKEMOD_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLHIKKAKEMOD(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); SEXP impl_ta_CDLHIKKAKE(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLHOMINGPIGEON_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLHOMINGPIGEON(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLIDENTICAL3CROWS_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLIDENTICAL3CROWS(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLINNECK_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLINNECK(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLINVERTEDHAMMER_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLINVERTEDHAMMER(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLKICKINGBYLENGTH_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLKICKINGBYLENGTH(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLKICKING_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLKICKING(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLLADDERBOTTOM_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLLADDERBOTTOM(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLLONGLEGGEDDOJI_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLLONGLEGGEDDOJI(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLLONGLINE_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLLONGLINE(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLMARUBOZU_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLMARUBOZU(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLMATCHINGLOW_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLMATCHINGLOW(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLMATHOLD_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInPenetration); SEXP impl_ta_CDLMATHOLD(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInPenetration, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLMORNINGDOJISTAR_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInPenetration); SEXP impl_ta_CDLMORNINGDOJISTAR(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInPenetration, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLMORNINGSTAR_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInPenetration); SEXP impl_ta_CDLMORNINGSTAR(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInPenetration, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLONNECK_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLONNECK(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLPIERCING_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLPIERCING(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLRICKSHAWMAN_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLRICKSHAWMAN(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLRISEFALL3METHODS_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLRISEFALL3METHODS(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLSEPARATINGLINES_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLSEPARATINGLINES(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLSHOOTINGSTAR_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLSHOOTINGSTAR(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLSHORTLINE_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLSHORTLINE(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLSPINNINGTOP_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLSPINNINGTOP(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLSTALLEDPATTERN_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLSTALLEDPATTERN(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLSTICKSANDWICH_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLSTICKSANDWICH(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLTAKURI_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLTAKURI(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLTASUKIGAP_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLTASUKIGAP(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLTHRUSTING_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLTHRUSTING(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLTRISTAR_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLTRISTAR(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLUNIQUE3RIVER_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLUNIQUE3RIVER(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLUPSIDEGAP2CROWS_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLUPSIDEGAP2CROWS(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CDLXSIDEGAP3METHODS_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_CDLXSIDEGAP3METHODS(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); +SEXP impl_ta_CMO_lookback(SEXP inReal, SEXP optInTimePeriod); SEXP impl_ta_CMO(SEXP inReal, SEXP optInTimePeriod, SEXP na_bridge); +SEXP impl_ta_CORREL_lookback(SEXP inReal0, SEXP inReal1, SEXP optInTimePeriod); SEXP impl_ta_CORREL(SEXP inReal0, SEXP inReal1, SEXP optInTimePeriod, SEXP na_bridge); +SEXP impl_ta_DEMA_lookback(SEXP inReal, SEXP optInTimePeriod); SEXP impl_ta_DEMA(SEXP inReal, SEXP optInTimePeriod, SEXP na_bridge); +SEXP impl_ta_DX_lookback(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod); SEXP impl_ta_DX(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod, SEXP na_bridge); +SEXP impl_ta_EMA_lookback(SEXP inReal, SEXP optInTimePeriod); SEXP impl_ta_EMA(SEXP inReal, SEXP optInTimePeriod, SEXP na_bridge); +SEXP impl_ta_HT_DCPERIOD_lookback(SEXP inReal); SEXP impl_ta_HT_DCPERIOD(SEXP inReal, SEXP na_bridge); +SEXP impl_ta_HT_DCPHASE_lookback(SEXP inReal); SEXP impl_ta_HT_DCPHASE(SEXP inReal, SEXP na_bridge); +SEXP impl_ta_HT_PHASOR_lookback(SEXP inReal); SEXP impl_ta_HT_PHASOR(SEXP inReal, SEXP na_bridge); +SEXP impl_ta_HT_SINE_lookback(SEXP inReal); SEXP impl_ta_HT_SINE(SEXP inReal, SEXP na_bridge); +SEXP impl_ta_HT_TRENDLINE_lookback(SEXP inReal); SEXP impl_ta_HT_TRENDLINE(SEXP inReal, SEXP na_bridge); +SEXP impl_ta_HT_TRENDMODE_lookback(SEXP inReal); SEXP impl_ta_HT_TRENDMODE(SEXP inReal, SEXP na_bridge); +SEXP impl_ta_IMI_lookback(SEXP inOpen, SEXP inClose, SEXP optInTimePeriod); SEXP impl_ta_IMI(SEXP inOpen, SEXP inClose, SEXP optInTimePeriod, SEXP na_bridge); +SEXP impl_ta_KAMA_lookback(SEXP inReal, SEXP optInTimePeriod); SEXP impl_ta_KAMA(SEXP inReal, SEXP optInTimePeriod, SEXP na_bridge); +SEXP impl_ta_MACDEXT_lookback(SEXP inReal, SEXP optInFastPeriod, SEXP optInFastMAType, SEXP optInSlowPeriod, SEXP optInSlowMAType, SEXP optInSignalPeriod, SEXP optInSignalMAType); SEXP impl_ta_MACDEXT(SEXP inReal, SEXP optInFastPeriod, SEXP optInFastMAType, SEXP optInSlowPeriod, SEXP optInSlowMAType, SEXP optInSignalPeriod, SEXP optInSignalMAType, SEXP na_bridge); +SEXP impl_ta_MACDFIX_lookback(SEXP inReal, SEXP optInSignalPeriod); SEXP impl_ta_MACDFIX(SEXP inReal, SEXP optInSignalPeriod, SEXP na_bridge); +SEXP impl_ta_MACD_lookback(SEXP inReal, SEXP optInFastPeriod, SEXP optInSlowPeriod, SEXP optInSignalPeriod); SEXP impl_ta_MACD(SEXP inReal, SEXP optInFastPeriod, SEXP optInSlowPeriod, SEXP optInSignalPeriod, SEXP na_bridge); +SEXP impl_ta_MAMA_lookback(SEXP inReal, SEXP optInFastLimit, SEXP optInSlowLimit); SEXP impl_ta_MAMA(SEXP inReal, SEXP optInFastLimit, SEXP optInSlowLimit, SEXP na_bridge); +SEXP impl_ta_MAX_lookback(SEXP inReal, SEXP optInTimePeriod); SEXP impl_ta_MAX(SEXP inReal, SEXP optInTimePeriod, SEXP na_bridge); +SEXP impl_ta_MEDPRICE_lookback(SEXP inHigh, SEXP inLow); SEXP impl_ta_MEDPRICE(SEXP inHigh, SEXP inLow, SEXP na_bridge); +SEXP impl_ta_MFI_lookback(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP inVolume, SEXP optInTimePeriod); SEXP impl_ta_MFI(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP inVolume, SEXP optInTimePeriod, SEXP na_bridge); +SEXP impl_ta_MIDPRICE_lookback(SEXP inHigh, SEXP inLow, SEXP optInTimePeriod); SEXP impl_ta_MIDPRICE(SEXP inHigh, SEXP inLow, SEXP optInTimePeriod, SEXP na_bridge); +SEXP impl_ta_MIN_lookback(SEXP inReal, SEXP optInTimePeriod); SEXP impl_ta_MIN(SEXP inReal, SEXP optInTimePeriod, SEXP na_bridge); +SEXP impl_ta_MINUS_DI_lookback(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod); SEXP impl_ta_MINUS_DI(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod, SEXP na_bridge); +SEXP impl_ta_MINUS_DM_lookback(SEXP inHigh, SEXP inLow, SEXP optInTimePeriod); SEXP impl_ta_MINUS_DM(SEXP inHigh, SEXP inLow, SEXP optInTimePeriod, SEXP na_bridge); +SEXP impl_ta_MOM_lookback(SEXP inReal, SEXP optInTimePeriod); SEXP impl_ta_MOM(SEXP inReal, SEXP optInTimePeriod, SEXP na_bridge); +SEXP impl_ta_NATR_lookback(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod); SEXP impl_ta_NATR(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod, SEXP na_bridge); +SEXP impl_ta_OBV_lookback(SEXP inReal, SEXP inVolume); SEXP impl_ta_OBV(SEXP inReal, SEXP inVolume, SEXP na_bridge); +SEXP impl_ta_PLUS_DI_lookback(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod); SEXP impl_ta_PLUS_DI(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod, SEXP na_bridge); +SEXP impl_ta_PLUS_DM_lookback(SEXP inHigh, SEXP inLow, SEXP optInTimePeriod); SEXP impl_ta_PLUS_DM(SEXP inHigh, SEXP inLow, SEXP optInTimePeriod, SEXP na_bridge); +SEXP impl_ta_PPO_lookback(SEXP inReal, SEXP optInFastPeriod, SEXP optInSlowPeriod, SEXP optInMAType); SEXP impl_ta_PPO(SEXP inReal, SEXP optInFastPeriod, SEXP optInSlowPeriod, SEXP optInMAType, SEXP na_bridge); +SEXP impl_ta_ROC_lookback(SEXP inReal, SEXP optInTimePeriod); +SEXP impl_ta_ROCR_lookback(SEXP inReal, SEXP optInTimePeriod); SEXP impl_ta_ROCR(SEXP inReal, SEXP optInTimePeriod, SEXP na_bridge); SEXP impl_ta_ROC(SEXP inReal, SEXP optInTimePeriod, SEXP na_bridge); +SEXP impl_ta_RSI_lookback(SEXP inReal, SEXP optInTimePeriod); SEXP impl_ta_RSI(SEXP inReal, SEXP optInTimePeriod, SEXP na_bridge); +SEXP impl_ta_SAREXT_lookback(SEXP inHigh, SEXP inLow, SEXP optInStartValue, SEXP optInOffsetOnReverse, SEXP optInAccelerationInitLong, SEXP optInAccelerationLong, SEXP optInAccelerationMaxLong, SEXP optInAccelerationInitShort, SEXP optInAccelerationShort, SEXP optInAccelerationMaxShort); SEXP impl_ta_SAREXT(SEXP inHigh, SEXP inLow, SEXP optInStartValue, SEXP optInOffsetOnReverse, SEXP optInAccelerationInitLong, SEXP optInAccelerationLong, SEXP optInAccelerationMaxLong, SEXP optInAccelerationInitShort, SEXP optInAccelerationShort, SEXP optInAccelerationMaxShort, SEXP na_bridge); +SEXP impl_ta_SAR_lookback(SEXP inHigh, SEXP inLow, SEXP optInAcceleration, SEXP optInMaximum); SEXP impl_ta_SAR(SEXP inHigh, SEXP inLow, SEXP optInAcceleration, SEXP optInMaximum, SEXP na_bridge); +SEXP impl_ta_SMA_lookback(SEXP inReal, SEXP optInTimePeriod); SEXP impl_ta_SMA(SEXP inReal, SEXP optInTimePeriod, SEXP na_bridge); +SEXP impl_ta_STDDEV_lookback(SEXP inReal, SEXP optInTimePeriod, SEXP optInNbDev); SEXP impl_ta_STDDEV(SEXP inReal, SEXP optInTimePeriod, SEXP optInNbDev, SEXP na_bridge); +SEXP impl_ta_STOCHF_lookback(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInFastK_Period, SEXP optInFastD_Period, SEXP optInFastD_MAType); SEXP impl_ta_STOCHF(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInFastK_Period, SEXP optInFastD_Period, SEXP optInFastD_MAType, SEXP na_bridge); +SEXP impl_ta_STOCH_lookback(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInFastK_Period, SEXP optInSlowK_Period, SEXP optInSlowK_MAType, SEXP optInSlowD_Period, SEXP optInSlowD_MAType); +SEXP impl_ta_STOCHRSI_lookback(SEXP inReal, SEXP optInTimePeriod, SEXP optInFastK_Period, SEXP optInFastD_Period, SEXP optInFastD_MAType); SEXP impl_ta_STOCHRSI(SEXP inReal, SEXP optInTimePeriod, SEXP optInFastK_Period, SEXP optInFastD_Period, SEXP optInFastD_MAType, SEXP na_bridge); SEXP impl_ta_STOCH(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInFastK_Period, SEXP optInSlowK_Period, SEXP optInSlowK_MAType, SEXP optInSlowD_Period, SEXP optInSlowD_MAType, SEXP na_bridge); +SEXP impl_ta_SUM_lookback(SEXP inReal, SEXP optInTimePeriod); SEXP impl_ta_SUM(SEXP inReal, SEXP optInTimePeriod, SEXP na_bridge); +SEXP impl_ta_T3_lookback(SEXP inReal, SEXP optInTimePeriod, SEXP optInVFactor); SEXP impl_ta_T3(SEXP inReal, SEXP optInTimePeriod, SEXP optInVFactor, SEXP na_bridge); +SEXP impl_ta_TEMA_lookback(SEXP inReal, SEXP optInTimePeriod); SEXP impl_ta_TEMA(SEXP inReal, SEXP optInTimePeriod, SEXP na_bridge); +SEXP impl_ta_TRANGE_lookback(SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_TRANGE(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP na_bridge); +SEXP impl_ta_TRIMA_lookback(SEXP inReal, SEXP optInTimePeriod); SEXP impl_ta_TRIMA(SEXP inReal, SEXP optInTimePeriod, SEXP na_bridge); +SEXP impl_ta_TRIX_lookback(SEXP inReal, SEXP optInTimePeriod); SEXP impl_ta_TRIX(SEXP inReal, SEXP optInTimePeriod, SEXP na_bridge); +SEXP impl_ta_TYPPRICE_lookback(SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_TYPPRICE(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP na_bridge); +SEXP impl_ta_ULTOSC_lookback(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod1, SEXP optInTimePeriod2, SEXP optInTimePeriod3); SEXP impl_ta_ULTOSC(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod1, SEXP optInTimePeriod2, SEXP optInTimePeriod3, SEXP na_bridge); +SEXP impl_ta_VAR_lookback(SEXP inReal, SEXP optInTimePeriod, SEXP optInNbDev); SEXP impl_ta_VAR(SEXP inReal, SEXP optInTimePeriod, SEXP optInNbDev, SEXP na_bridge); +SEXP impl_ta_VOLUME_lookback(SEXP inReal, SEXP maSpec); SEXP impl_ta_VOLUME(SEXP inReal, SEXP maSpec, SEXP na_rm); +SEXP impl_ta_WCLPRICE_lookback(SEXP inHigh, SEXP inLow, SEXP inClose); SEXP impl_ta_WCLPRICE(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP na_bridge); +SEXP impl_ta_WILLR_lookback(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod); SEXP impl_ta_WILLR(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod, SEXP na_bridge); +SEXP impl_ta_WMA_lookback(SEXP inReal, SEXP optInTimePeriod); SEXP impl_ta_WMA(SEXP inReal, SEXP optInTimePeriod, SEXP na_bridge); SEXP initialize_ta_lib(void); SEXP map_dfr_double(SEXP x); diff --git a/src/init.c b/src/init.c index a245ced9..cc2fe091 100644 --- a/src/init.c +++ b/src/init.c @@ -11,133 +11,261 @@ // clang-format on static const R_CallMethodDef CallEntries[] = { + CALLDEF(impl_ta_ACCBANDS_lookback, 4), CALLDEF(impl_ta_ACCBANDS, 5), + CALLDEF(impl_ta_AD_lookback, 4), + CALLDEF(impl_ta_ADOSC_lookback, 6), CALLDEF(impl_ta_ADOSC, 7), CALLDEF(impl_ta_AD, 5), + CALLDEF(impl_ta_ADX_lookback, 4), + CALLDEF(impl_ta_ADXR_lookback, 4), CALLDEF(impl_ta_ADXR, 5), CALLDEF(impl_ta_ADX, 5), + CALLDEF(impl_ta_APO_lookback, 4), CALLDEF(impl_ta_APO, 5), + CALLDEF(impl_ta_AROON_lookback, 3), + CALLDEF(impl_ta_AROONOSC_lookback, 3), CALLDEF(impl_ta_AROONOSC, 4), CALLDEF(impl_ta_AROON, 4), + CALLDEF(impl_ta_ATR_lookback, 4), CALLDEF(impl_ta_ATR, 5), + CALLDEF(impl_ta_AVGPRICE_lookback, 4), CALLDEF(impl_ta_AVGPRICE, 5), + CALLDEF(impl_ta_BBANDS_lookback, 5), CALLDEF(impl_ta_BBANDS, 6), + CALLDEF(impl_ta_BETA_lookback, 3), CALLDEF(impl_ta_BETA, 4), + CALLDEF(impl_ta_BOP_lookback, 4), CALLDEF(impl_ta_BOP, 5), + CALLDEF(impl_ta_CCI_lookback, 4), CALLDEF(impl_ta_CCI, 5), + CALLDEF(impl_ta_CDL2CROWS_lookback, 4), CALLDEF(impl_ta_CDL2CROWS, 6), + CALLDEF(impl_ta_CDL3BLACKCROWS_lookback, 4), CALLDEF(impl_ta_CDL3BLACKCROWS, 6), + CALLDEF(impl_ta_CDL3INSIDE_lookback, 4), CALLDEF(impl_ta_CDL3INSIDE, 6), + CALLDEF(impl_ta_CDL3LINESTRIKE_lookback, 4), CALLDEF(impl_ta_CDL3LINESTRIKE, 6), + CALLDEF(impl_ta_CDL3OUTSIDE_lookback, 4), CALLDEF(impl_ta_CDL3OUTSIDE, 6), + CALLDEF(impl_ta_CDL3STARSINSOUTH_lookback, 4), CALLDEF(impl_ta_CDL3STARSINSOUTH, 6), + CALLDEF(impl_ta_CDL3WHITESOLDIERS_lookback, 4), CALLDEF(impl_ta_CDL3WHITESOLDIERS, 6), + CALLDEF(impl_ta_CDLABANDONEDBABY_lookback, 5), CALLDEF(impl_ta_CDLABANDONEDBABY, 7), + CALLDEF(impl_ta_CDLADVANCEBLOCK_lookback, 4), CALLDEF(impl_ta_CDLADVANCEBLOCK, 6), + CALLDEF(impl_ta_CDLBELTHOLD_lookback, 4), CALLDEF(impl_ta_CDLBELTHOLD, 6), + CALLDEF(impl_ta_CDLBREAKAWAY_lookback, 4), CALLDEF(impl_ta_CDLBREAKAWAY, 6), + CALLDEF(impl_ta_CDLCLOSINGMARUBOZU_lookback, 4), CALLDEF(impl_ta_CDLCLOSINGMARUBOZU, 6), + CALLDEF(impl_ta_CDLCONCEALBABYSWALL_lookback, 4), CALLDEF(impl_ta_CDLCONCEALBABYSWALL, 6), + CALLDEF(impl_ta_CDLCOUNTERATTACK_lookback, 4), CALLDEF(impl_ta_CDLCOUNTERATTACK, 6), + CALLDEF(impl_ta_CDLDARKCLOUDCOVER_lookback, 5), CALLDEF(impl_ta_CDLDARKCLOUDCOVER, 7), + CALLDEF(impl_ta_CDLDOJI_lookback, 4), CALLDEF(impl_ta_CDLDOJI, 6), + CALLDEF(impl_ta_CDLDOJISTAR_lookback, 4), CALLDEF(impl_ta_CDLDOJISTAR, 6), + CALLDEF(impl_ta_CDLDRAGONFLYDOJI_lookback, 4), CALLDEF(impl_ta_CDLDRAGONFLYDOJI, 6), + CALLDEF(impl_ta_CDLENGULFING_lookback, 4), CALLDEF(impl_ta_CDLENGULFING, 6), + CALLDEF(impl_ta_CDLEVENINGDOJISTAR_lookback, 5), CALLDEF(impl_ta_CDLEVENINGDOJISTAR, 7), + CALLDEF(impl_ta_CDLEVENINGSTAR_lookback, 5), CALLDEF(impl_ta_CDLEVENINGSTAR, 7), + CALLDEF(impl_ta_CDLGAPSIDESIDEWHITE_lookback, 4), CALLDEF(impl_ta_CDLGAPSIDESIDEWHITE, 6), + CALLDEF(impl_ta_CDLGRAVESTONEDOJI_lookback, 4), CALLDEF(impl_ta_CDLGRAVESTONEDOJI, 6), + CALLDEF(impl_ta_CDLHAMMER_lookback, 4), CALLDEF(impl_ta_CDLHAMMER, 6), + CALLDEF(impl_ta_CDLHANGINGMAN_lookback, 4), CALLDEF(impl_ta_CDLHANGINGMAN, 6), + CALLDEF(impl_ta_CDLHARAMICROSS_lookback, 4), CALLDEF(impl_ta_CDLHARAMICROSS, 6), + CALLDEF(impl_ta_CDLHARAMI_lookback, 4), CALLDEF(impl_ta_CDLHARAMI, 6), + CALLDEF(impl_ta_CDLHIGHWAVE_lookback, 4), CALLDEF(impl_ta_CDLHIGHWAVE, 6), + CALLDEF(impl_ta_CDLHIKKAKE_lookback, 4), + CALLDEF(impl_ta_CDLHIKKAKEMOD_lookback, 4), CALLDEF(impl_ta_CDLHIKKAKEMOD, 6), CALLDEF(impl_ta_CDLHIKKAKE, 6), + CALLDEF(impl_ta_CDLHOMINGPIGEON_lookback, 4), CALLDEF(impl_ta_CDLHOMINGPIGEON, 6), + CALLDEF(impl_ta_CDLIDENTICAL3CROWS_lookback, 4), CALLDEF(impl_ta_CDLIDENTICAL3CROWS, 6), + CALLDEF(impl_ta_CDLINNECK_lookback, 4), CALLDEF(impl_ta_CDLINNECK, 6), + CALLDEF(impl_ta_CDLINVERTEDHAMMER_lookback, 4), CALLDEF(impl_ta_CDLINVERTEDHAMMER, 6), + CALLDEF(impl_ta_CDLKICKINGBYLENGTH_lookback, 4), CALLDEF(impl_ta_CDLKICKINGBYLENGTH, 6), + CALLDEF(impl_ta_CDLKICKING_lookback, 4), CALLDEF(impl_ta_CDLKICKING, 6), + CALLDEF(impl_ta_CDLLADDERBOTTOM_lookback, 4), CALLDEF(impl_ta_CDLLADDERBOTTOM, 6), + CALLDEF(impl_ta_CDLLONGLEGGEDDOJI_lookback, 4), CALLDEF(impl_ta_CDLLONGLEGGEDDOJI, 6), + CALLDEF(impl_ta_CDLLONGLINE_lookback, 4), CALLDEF(impl_ta_CDLLONGLINE, 6), + CALLDEF(impl_ta_CDLMARUBOZU_lookback, 4), CALLDEF(impl_ta_CDLMARUBOZU, 6), + CALLDEF(impl_ta_CDLMATCHINGLOW_lookback, 4), CALLDEF(impl_ta_CDLMATCHINGLOW, 6), + CALLDEF(impl_ta_CDLMATHOLD_lookback, 5), CALLDEF(impl_ta_CDLMATHOLD, 7), + CALLDEF(impl_ta_CDLMORNINGDOJISTAR_lookback, 5), CALLDEF(impl_ta_CDLMORNINGDOJISTAR, 7), + CALLDEF(impl_ta_CDLMORNINGSTAR_lookback, 5), CALLDEF(impl_ta_CDLMORNINGSTAR, 7), + CALLDEF(impl_ta_CDLONNECK_lookback, 4), CALLDEF(impl_ta_CDLONNECK, 6), + CALLDEF(impl_ta_CDLPIERCING_lookback, 4), CALLDEF(impl_ta_CDLPIERCING, 6), + CALLDEF(impl_ta_CDLRICKSHAWMAN_lookback, 4), CALLDEF(impl_ta_CDLRICKSHAWMAN, 6), + CALLDEF(impl_ta_CDLRISEFALL3METHODS_lookback, 4), CALLDEF(impl_ta_CDLRISEFALL3METHODS, 6), + CALLDEF(impl_ta_CDLSEPARATINGLINES_lookback, 4), CALLDEF(impl_ta_CDLSEPARATINGLINES, 6), + CALLDEF(impl_ta_CDLSHOOTINGSTAR_lookback, 4), CALLDEF(impl_ta_CDLSHOOTINGSTAR, 6), + CALLDEF(impl_ta_CDLSHORTLINE_lookback, 4), CALLDEF(impl_ta_CDLSHORTLINE, 6), + CALLDEF(impl_ta_CDLSPINNINGTOP_lookback, 4), CALLDEF(impl_ta_CDLSPINNINGTOP, 6), + CALLDEF(impl_ta_CDLSTALLEDPATTERN_lookback, 4), CALLDEF(impl_ta_CDLSTALLEDPATTERN, 6), + CALLDEF(impl_ta_CDLSTICKSANDWICH_lookback, 4), CALLDEF(impl_ta_CDLSTICKSANDWICH, 6), + CALLDEF(impl_ta_CDLTAKURI_lookback, 4), CALLDEF(impl_ta_CDLTAKURI, 6), + CALLDEF(impl_ta_CDLTASUKIGAP_lookback, 4), CALLDEF(impl_ta_CDLTASUKIGAP, 6), + CALLDEF(impl_ta_CDLTHRUSTING_lookback, 4), CALLDEF(impl_ta_CDLTHRUSTING, 6), + CALLDEF(impl_ta_CDLTRISTAR_lookback, 4), CALLDEF(impl_ta_CDLTRISTAR, 6), + CALLDEF(impl_ta_CDLUNIQUE3RIVER_lookback, 4), CALLDEF(impl_ta_CDLUNIQUE3RIVER, 6), + CALLDEF(impl_ta_CDLUPSIDEGAP2CROWS_lookback, 4), CALLDEF(impl_ta_CDLUPSIDEGAP2CROWS, 6), + CALLDEF(impl_ta_CDLXSIDEGAP3METHODS_lookback, 4), CALLDEF(impl_ta_CDLXSIDEGAP3METHODS, 6), + CALLDEF(impl_ta_CMO_lookback, 2), CALLDEF(impl_ta_CMO, 3), + CALLDEF(impl_ta_CORREL_lookback, 3), CALLDEF(impl_ta_CORREL, 4), + CALLDEF(impl_ta_DEMA_lookback, 2), CALLDEF(impl_ta_DEMA, 3), + CALLDEF(impl_ta_DX_lookback, 4), CALLDEF(impl_ta_DX, 5), + CALLDEF(impl_ta_EMA_lookback, 2), CALLDEF(impl_ta_EMA, 3), + CALLDEF(impl_ta_HT_DCPERIOD_lookback, 1), CALLDEF(impl_ta_HT_DCPERIOD, 2), + CALLDEF(impl_ta_HT_DCPHASE_lookback, 1), CALLDEF(impl_ta_HT_DCPHASE, 2), + CALLDEF(impl_ta_HT_PHASOR_lookback, 1), CALLDEF(impl_ta_HT_PHASOR, 2), + CALLDEF(impl_ta_HT_SINE_lookback, 1), CALLDEF(impl_ta_HT_SINE, 2), + CALLDEF(impl_ta_HT_TRENDLINE_lookback, 1), CALLDEF(impl_ta_HT_TRENDLINE, 2), + CALLDEF(impl_ta_HT_TRENDMODE_lookback, 1), CALLDEF(impl_ta_HT_TRENDMODE, 2), + CALLDEF(impl_ta_IMI_lookback, 3), CALLDEF(impl_ta_IMI, 4), + CALLDEF(impl_ta_KAMA_lookback, 2), CALLDEF(impl_ta_KAMA, 3), + CALLDEF(impl_ta_MACDEXT_lookback, 7), CALLDEF(impl_ta_MACDEXT, 8), + CALLDEF(impl_ta_MACDFIX_lookback, 2), CALLDEF(impl_ta_MACDFIX, 3), + CALLDEF(impl_ta_MACD_lookback, 4), CALLDEF(impl_ta_MACD, 5), + CALLDEF(impl_ta_MAMA_lookback, 3), CALLDEF(impl_ta_MAMA, 4), + CALLDEF(impl_ta_MAX_lookback, 2), CALLDEF(impl_ta_MAX, 3), + CALLDEF(impl_ta_MEDPRICE_lookback, 2), CALLDEF(impl_ta_MEDPRICE, 3), + CALLDEF(impl_ta_MFI_lookback, 5), CALLDEF(impl_ta_MFI, 6), + CALLDEF(impl_ta_MIDPRICE_lookback, 3), CALLDEF(impl_ta_MIDPRICE, 4), + CALLDEF(impl_ta_MIN_lookback, 2), CALLDEF(impl_ta_MIN, 3), + CALLDEF(impl_ta_MINUS_DI_lookback, 4), CALLDEF(impl_ta_MINUS_DI, 5), + CALLDEF(impl_ta_MINUS_DM_lookback, 3), CALLDEF(impl_ta_MINUS_DM, 4), + CALLDEF(impl_ta_MOM_lookback, 2), CALLDEF(impl_ta_MOM, 3), + CALLDEF(impl_ta_NATR_lookback, 4), CALLDEF(impl_ta_NATR, 5), + CALLDEF(impl_ta_OBV_lookback, 2), CALLDEF(impl_ta_OBV, 3), + CALLDEF(impl_ta_PLUS_DI_lookback, 4), CALLDEF(impl_ta_PLUS_DI, 5), + CALLDEF(impl_ta_PLUS_DM_lookback, 3), CALLDEF(impl_ta_PLUS_DM, 4), + CALLDEF(impl_ta_PPO_lookback, 4), CALLDEF(impl_ta_PPO, 5), + CALLDEF(impl_ta_ROC_lookback, 2), + CALLDEF(impl_ta_ROCR_lookback, 2), CALLDEF(impl_ta_ROCR, 3), CALLDEF(impl_ta_ROC, 3), + CALLDEF(impl_ta_RSI_lookback, 2), CALLDEF(impl_ta_RSI, 3), + CALLDEF(impl_ta_SAREXT_lookback, 10), CALLDEF(impl_ta_SAREXT, 11), + CALLDEF(impl_ta_SAR_lookback, 4), CALLDEF(impl_ta_SAR, 5), + CALLDEF(impl_ta_SMA_lookback, 2), CALLDEF(impl_ta_SMA, 3), + CALLDEF(impl_ta_STDDEV_lookback, 3), CALLDEF(impl_ta_STDDEV, 4), + CALLDEF(impl_ta_STOCHF_lookback, 6), CALLDEF(impl_ta_STOCHF, 7), + CALLDEF(impl_ta_STOCH_lookback, 8), + CALLDEF(impl_ta_STOCHRSI_lookback, 5), CALLDEF(impl_ta_STOCHRSI, 6), CALLDEF(impl_ta_STOCH, 9), + CALLDEF(impl_ta_SUM_lookback, 2), CALLDEF(impl_ta_SUM, 3), + CALLDEF(impl_ta_T3_lookback, 3), CALLDEF(impl_ta_T3, 4), + CALLDEF(impl_ta_TEMA_lookback, 2), CALLDEF(impl_ta_TEMA, 3), + CALLDEF(impl_ta_TRANGE_lookback, 3), CALLDEF(impl_ta_TRANGE, 4), + CALLDEF(impl_ta_TRIMA_lookback, 2), CALLDEF(impl_ta_TRIMA, 3), + CALLDEF(impl_ta_TRIX_lookback, 2), CALLDEF(impl_ta_TRIX, 3), + CALLDEF(impl_ta_TYPPRICE_lookback, 3), CALLDEF(impl_ta_TYPPRICE, 4), + CALLDEF(impl_ta_ULTOSC_lookback, 6), CALLDEF(impl_ta_ULTOSC, 7), + CALLDEF(impl_ta_VAR_lookback, 3), CALLDEF(impl_ta_VAR, 4), + CALLDEF(impl_ta_VOLUME_lookback, 2), CALLDEF(impl_ta_VOLUME, 3), + CALLDEF(impl_ta_WCLPRICE_lookback, 3), CALLDEF(impl_ta_WCLPRICE, 4), + CALLDEF(impl_ta_WILLR_lookback, 4), CALLDEF(impl_ta_WILLR, 5), + CALLDEF(impl_ta_WMA_lookback, 2), CALLDEF(impl_ta_WMA, 3), CALLDEF(initialize_ta_lib, 0), CALLDEF(map_dfr_double, 1), diff --git a/src/ta_ACCBANDS.c b/src/ta_ACCBANDS.c index 7fc4a395..71a71a48 100644 --- a/src/ta_ACCBANDS.c +++ b/src/ta_ACCBANDS.c @@ -24,6 +24,40 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_ACCBANDS_lookback( + SEXP inHigh, + SEXP inLow, + SEXP inClose, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inHigh' (assumes equal length across input) + int n = LENGTH(inHigh); + + // pointers to input arrays + const double *inHigh_ptr = REAL(inHigh); + const double *inLow_ptr = REAL(inLow); + const double *inClose_ptr = REAL(inClose); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_ACCBANDS_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_ACCBANDS( SEXP inHigh, diff --git a/src/ta_AD.c b/src/ta_AD.c index 0b765e71..62527a62 100644 --- a/src/ta_AD.c +++ b/src/ta_AD.c @@ -24,6 +24,38 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_AD_lookback( + SEXP inHigh, + SEXP inLow, + SEXP inClose, + SEXP inVolume +) +// clang-format on +{ + // values + // get length of 'inHigh' (assumes equal length across input) + int n = LENGTH(inHigh); + + // pointers to input arrays + const double *inHigh_ptr = REAL(inHigh); + const double *inLow_ptr = REAL(inLow); + const double *inClose_ptr = REAL(inClose); + const double *inVolume_ptr = REAL(inVolume); + + // calculate lookback + const int lookback = TA_AD_Lookback(); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_AD( SEXP inHigh, diff --git a/src/ta_ADOSC.c b/src/ta_ADOSC.c index f1dca97c..eaeae84d 100644 --- a/src/ta_ADOSC.c +++ b/src/ta_ADOSC.c @@ -26,6 +26,45 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_ADOSC_lookback( + SEXP inHigh, + SEXP inLow, + SEXP inClose, + SEXP inVolume, + SEXP optInFastPeriod, + SEXP optInSlowPeriod +) +// clang-format on +{ + // values + // get length of 'inHigh' (assumes equal length across input) + int n = LENGTH(inHigh); + + // pointers to input arrays + const double *inHigh_ptr = REAL(inHigh); + const double *inLow_ptr = REAL(inLow); + const double *inClose_ptr = REAL(inClose); + const double *inVolume_ptr = REAL(inVolume); + + // extract input values + const int optInFastPeriod_value = INTEGER(optInFastPeriod)[0]; + const int optInSlowPeriod_value = INTEGER(optInSlowPeriod)[0]; + + // calculate lookback + const int lookback = + TA_ADOSC_Lookback(optInFastPeriod_value, optInSlowPeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_ADOSC( SEXP inHigh, diff --git a/src/ta_ADX.c b/src/ta_ADX.c index 1a066ab4..7331352c 100644 --- a/src/ta_ADX.c +++ b/src/ta_ADX.c @@ -24,6 +24,40 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_ADX_lookback( + SEXP inHigh, + SEXP inLow, + SEXP inClose, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inHigh' (assumes equal length across input) + int n = LENGTH(inHigh); + + // pointers to input arrays + const double *inHigh_ptr = REAL(inHigh); + const double *inLow_ptr = REAL(inLow); + const double *inClose_ptr = REAL(inClose); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_ADX_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_ADX( SEXP inHigh, diff --git a/src/ta_ADXR.c b/src/ta_ADXR.c index 90dda863..41161776 100644 --- a/src/ta_ADXR.c +++ b/src/ta_ADXR.c @@ -24,6 +24,40 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_ADXR_lookback( + SEXP inHigh, + SEXP inLow, + SEXP inClose, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inHigh' (assumes equal length across input) + int n = LENGTH(inHigh); + + // pointers to input arrays + const double *inHigh_ptr = REAL(inHigh); + const double *inLow_ptr = REAL(inLow); + const double *inClose_ptr = REAL(inClose); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_ADXR_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_ADXR( SEXP inHigh, diff --git a/src/ta_APO.c b/src/ta_APO.c index f71189e3..f3892627 100644 --- a/src/ta_APO.c +++ b/src/ta_APO.c @@ -24,6 +24,43 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_APO_lookback( + SEXP inReal, + SEXP optInFastPeriod, + SEXP optInSlowPeriod, + SEXP optInMAType +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // extract input values + const int optInFastPeriod_value = INTEGER(optInFastPeriod)[0]; + const int optInSlowPeriod_value = INTEGER(optInSlowPeriod)[0]; + const TA_MAType optInMAType_value = as_MAType(optInMAType); + + // calculate lookback + const int lookback = TA_APO_Lookback( + optInFastPeriod_value, + optInSlowPeriod_value, + optInMAType_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_APO( SEXP inReal, diff --git a/src/ta_AROON.c b/src/ta_AROON.c index 948c9b94..5bf6a448 100644 --- a/src/ta_AROON.c +++ b/src/ta_AROON.c @@ -23,6 +23,38 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_AROON_lookback( + SEXP inHigh, + SEXP inLow, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inHigh' (assumes equal length across input) + int n = LENGTH(inHigh); + + // pointers to input arrays + const double *inHigh_ptr = REAL(inHigh); + const double *inLow_ptr = REAL(inLow); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_AROON_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_AROON( SEXP inHigh, diff --git a/src/ta_AROONOSC.c b/src/ta_AROONOSC.c index a0247912..c55d3ce4 100644 --- a/src/ta_AROONOSC.c +++ b/src/ta_AROONOSC.c @@ -23,6 +23,38 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_AROONOSC_lookback( + SEXP inHigh, + SEXP inLow, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inHigh' (assumes equal length across input) + int n = LENGTH(inHigh); + + // pointers to input arrays + const double *inHigh_ptr = REAL(inHigh); + const double *inLow_ptr = REAL(inLow); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_AROONOSC_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_AROONOSC( SEXP inHigh, diff --git a/src/ta_ATR.c b/src/ta_ATR.c index e9c41d9e..35a0bdea 100644 --- a/src/ta_ATR.c +++ b/src/ta_ATR.c @@ -24,6 +24,40 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_ATR_lookback( + SEXP inHigh, + SEXP inLow, + SEXP inClose, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inHigh' (assumes equal length across input) + int n = LENGTH(inHigh); + + // pointers to input arrays + const double *inHigh_ptr = REAL(inHigh); + const double *inLow_ptr = REAL(inLow); + const double *inClose_ptr = REAL(inClose); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_ATR_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_ATR( SEXP inHigh, diff --git a/src/ta_AVGPRICE.c b/src/ta_AVGPRICE.c index 1ea08e87..c74b13db 100644 --- a/src/ta_AVGPRICE.c +++ b/src/ta_AVGPRICE.c @@ -24,6 +24,38 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_AVGPRICE_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // values + // get length of 'inOpen' (assumes equal length across input) + int n = LENGTH(inOpen); + + // pointers to input arrays + const double *inOpen_ptr = REAL(inOpen); + const double *inHigh_ptr = REAL(inHigh); + const double *inLow_ptr = REAL(inLow); + const double *inClose_ptr = REAL(inClose); + + // calculate lookback + const int lookback = TA_AVGPRICE_Lookback(); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_AVGPRICE( SEXP inOpen, diff --git a/src/ta_BBANDS.c b/src/ta_BBANDS.c index 81f68e0d..e967720c 100644 --- a/src/ta_BBANDS.c +++ b/src/ta_BBANDS.c @@ -25,6 +25,46 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_BBANDS_lookback( + SEXP inReal, + SEXP optInTimePeriod, + SEXP optInNbDevUp, + SEXP optInNbDevDn, + SEXP optInMAType +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + const double optInNbDevUp_value = REAL(optInNbDevUp)[0]; + const double optInNbDevDn_value = REAL(optInNbDevDn)[0]; + const TA_MAType optInMAType_value = as_MAType(optInMAType); + + // calculate lookback + const int lookback = TA_BBANDS_Lookback( + optInTimePeriod_value, + optInNbDevUp_value, + optInNbDevDn_value, + optInMAType_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_BBANDS( SEXP inReal, diff --git a/src/ta_BETA.c b/src/ta_BETA.c index d1d0476f..bc804e02 100644 --- a/src/ta_BETA.c +++ b/src/ta_BETA.c @@ -23,6 +23,38 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_BETA_lookback( + SEXP inReal0, + SEXP inReal1, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inReal0' (assumes equal length across input) + int n = LENGTH(inReal0); + + // pointers to input arrays + const double *inReal0_ptr = REAL(inReal0); + const double *inReal1_ptr = REAL(inReal1); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_BETA_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_BETA( SEXP inReal0, diff --git a/src/ta_BOP.c b/src/ta_BOP.c index 430c1d55..5be28e9a 100644 --- a/src/ta_BOP.c +++ b/src/ta_BOP.c @@ -24,6 +24,38 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_BOP_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // values + // get length of 'inOpen' (assumes equal length across input) + int n = LENGTH(inOpen); + + // pointers to input arrays + const double *inOpen_ptr = REAL(inOpen); + const double *inHigh_ptr = REAL(inHigh); + const double *inLow_ptr = REAL(inLow); + const double *inClose_ptr = REAL(inClose); + + // calculate lookback + const int lookback = TA_BOP_Lookback(); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_BOP( SEXP inOpen, diff --git a/src/ta_CCI.c b/src/ta_CCI.c index 467dfd77..1d534321 100644 --- a/src/ta_CCI.c +++ b/src/ta_CCI.c @@ -24,6 +24,40 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CCI_lookback( + SEXP inHigh, + SEXP inLow, + SEXP inClose, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inHigh' (assumes equal length across input) + int n = LENGTH(inHigh); + + // pointers to input arrays + const double *inHigh_ptr = REAL(inHigh); + const double *inLow_ptr = REAL(inLow); + const double *inClose_ptr = REAL(inClose); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_CCI_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_CCI( SEXP inHigh, diff --git a/src/ta_CDL2CROWS.c b/src/ta_CDL2CROWS.c index 0ba19c78..004fbdaa 100644 --- a/src/ta_CDL2CROWS.c +++ b/src/ta_CDL2CROWS.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDL2CROWS_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDL2CROWS_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDL2CROWS( SEXP inOpen, diff --git a/src/ta_CDL3BLACKCROWS.c b/src/ta_CDL3BLACKCROWS.c index 2119b952..233206f7 100644 --- a/src/ta_CDL3BLACKCROWS.c +++ b/src/ta_CDL3BLACKCROWS.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDL3BLACKCROWS_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDL3BLACKCROWS_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDL3BLACKCROWS( SEXP inOpen, diff --git a/src/ta_CDL3INSIDE.c b/src/ta_CDL3INSIDE.c index 23220d6a..cde4c4e2 100644 --- a/src/ta_CDL3INSIDE.c +++ b/src/ta_CDL3INSIDE.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDL3INSIDE_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDL3INSIDE_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDL3INSIDE( SEXP inOpen, diff --git a/src/ta_CDL3LINESTRIKE.c b/src/ta_CDL3LINESTRIKE.c index a0ee4b6e..6bbd86e4 100644 --- a/src/ta_CDL3LINESTRIKE.c +++ b/src/ta_CDL3LINESTRIKE.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDL3LINESTRIKE_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDL3LINESTRIKE_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDL3LINESTRIKE( SEXP inOpen, diff --git a/src/ta_CDL3OUTSIDE.c b/src/ta_CDL3OUTSIDE.c index 5cf16e81..d090b8e8 100644 --- a/src/ta_CDL3OUTSIDE.c +++ b/src/ta_CDL3OUTSIDE.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDL3OUTSIDE_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDL3OUTSIDE_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDL3OUTSIDE( SEXP inOpen, diff --git a/src/ta_CDL3STARSINSOUTH.c b/src/ta_CDL3STARSINSOUTH.c index 93083dc4..2b16cb16 100644 --- a/src/ta_CDL3STARSINSOUTH.c +++ b/src/ta_CDL3STARSINSOUTH.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDL3STARSINSOUTH_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDL3STARSINSOUTH_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDL3STARSINSOUTH( SEXP inOpen, diff --git a/src/ta_CDL3WHITESOLDIERS.c b/src/ta_CDL3WHITESOLDIERS.c index d0cfd8ef..adfe188b 100644 --- a/src/ta_CDL3WHITESOLDIERS.c +++ b/src/ta_CDL3WHITESOLDIERS.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDL3WHITESOLDIERS_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDL3WHITESOLDIERS_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDL3WHITESOLDIERS( SEXP inOpen, diff --git a/src/ta_CDLABANDONEDBABY.c b/src/ta_CDLABANDONEDBABY.c index af02a6a2..b6198a46 100644 --- a/src/ta_CDLABANDONEDBABY.c +++ b/src/ta_CDLABANDONEDBABY.c @@ -25,6 +25,38 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLABANDONEDBABY_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose, + SEXP optInPenetration +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + const double penetration = REAL(optInPenetration)[0]; + + // calculate lookback + const int lookback = TA_CDLABANDONEDBABY_Lookback(penetration); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLABANDONEDBABY( SEXP inOpen, diff --git a/src/ta_CDLADVANCEBLOCK.c b/src/ta_CDLADVANCEBLOCK.c index 2ddb9f16..ee38fc0b 100644 --- a/src/ta_CDLADVANCEBLOCK.c +++ b/src/ta_CDLADVANCEBLOCK.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLADVANCEBLOCK_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLADVANCEBLOCK_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLADVANCEBLOCK( SEXP inOpen, diff --git a/src/ta_CDLBELTHOLD.c b/src/ta_CDLBELTHOLD.c index 86e808c2..783e9c80 100644 --- a/src/ta_CDLBELTHOLD.c +++ b/src/ta_CDLBELTHOLD.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLBELTHOLD_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLBELTHOLD_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLBELTHOLD( SEXP inOpen, diff --git a/src/ta_CDLBREAKAWAY.c b/src/ta_CDLBREAKAWAY.c index 122ca67d..f777a39c 100644 --- a/src/ta_CDLBREAKAWAY.c +++ b/src/ta_CDLBREAKAWAY.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLBREAKAWAY_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLBREAKAWAY_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLBREAKAWAY( SEXP inOpen, diff --git a/src/ta_CDLCLOSINGMARUBOZU.c b/src/ta_CDLCLOSINGMARUBOZU.c index 35b7f2e8..ab2bf402 100644 --- a/src/ta_CDLCLOSINGMARUBOZU.c +++ b/src/ta_CDLCLOSINGMARUBOZU.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLCLOSINGMARUBOZU_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLCLOSINGMARUBOZU_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLCLOSINGMARUBOZU( SEXP inOpen, diff --git a/src/ta_CDLCONCEALBABYSWALL.c b/src/ta_CDLCONCEALBABYSWALL.c index 31c1e9d9..d194d45d 100644 --- a/src/ta_CDLCONCEALBABYSWALL.c +++ b/src/ta_CDLCONCEALBABYSWALL.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLCONCEALBABYSWALL_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLCONCEALBABYSWALL_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLCONCEALBABYSWALL( SEXP inOpen, diff --git a/src/ta_CDLCOUNTERATTACK.c b/src/ta_CDLCOUNTERATTACK.c index ecc8e9f7..3856d594 100644 --- a/src/ta_CDLCOUNTERATTACK.c +++ b/src/ta_CDLCOUNTERATTACK.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLCOUNTERATTACK_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLCOUNTERATTACK_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLCOUNTERATTACK( SEXP inOpen, diff --git a/src/ta_CDLDARKCLOUDCOVER.c b/src/ta_CDLDARKCLOUDCOVER.c index 9abf0809..27b11bc2 100644 --- a/src/ta_CDLDARKCLOUDCOVER.c +++ b/src/ta_CDLDARKCLOUDCOVER.c @@ -25,6 +25,38 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLDARKCLOUDCOVER_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose, + SEXP optInPenetration +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + const double penetration = REAL(optInPenetration)[0]; + + // calculate lookback + const int lookback = TA_CDLDARKCLOUDCOVER_Lookback(penetration); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLDARKCLOUDCOVER( SEXP inOpen, diff --git a/src/ta_CDLDOJI.c b/src/ta_CDLDOJI.c index e9faf5f8..9785ae20 100644 --- a/src/ta_CDLDOJI.c +++ b/src/ta_CDLDOJI.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLDOJI_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLDOJI_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLDOJI( SEXP inOpen, diff --git a/src/ta_CDLDOJISTAR.c b/src/ta_CDLDOJISTAR.c index 9241eeaa..e9f06bfc 100644 --- a/src/ta_CDLDOJISTAR.c +++ b/src/ta_CDLDOJISTAR.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLDOJISTAR_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLDOJISTAR_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLDOJISTAR( SEXP inOpen, diff --git a/src/ta_CDLDRAGONFLYDOJI.c b/src/ta_CDLDRAGONFLYDOJI.c index 03be99e1..27b3b574 100644 --- a/src/ta_CDLDRAGONFLYDOJI.c +++ b/src/ta_CDLDRAGONFLYDOJI.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLDRAGONFLYDOJI_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLDRAGONFLYDOJI_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLDRAGONFLYDOJI( SEXP inOpen, diff --git a/src/ta_CDLENGULFING.c b/src/ta_CDLENGULFING.c index 8dbb06d8..c399e015 100644 --- a/src/ta_CDLENGULFING.c +++ b/src/ta_CDLENGULFING.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLENGULFING_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLENGULFING_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLENGULFING( SEXP inOpen, diff --git a/src/ta_CDLEVENINGDOJISTAR.c b/src/ta_CDLEVENINGDOJISTAR.c index ba51e0f0..ef7aab8c 100644 --- a/src/ta_CDLEVENINGDOJISTAR.c +++ b/src/ta_CDLEVENINGDOJISTAR.c @@ -25,6 +25,38 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLEVENINGDOJISTAR_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose, + SEXP optInPenetration +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + const double penetration = REAL(optInPenetration)[0]; + + // calculate lookback + const int lookback = TA_CDLEVENINGDOJISTAR_Lookback(penetration); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLEVENINGDOJISTAR( SEXP inOpen, diff --git a/src/ta_CDLEVENINGSTAR.c b/src/ta_CDLEVENINGSTAR.c index 1b82c572..67852193 100644 --- a/src/ta_CDLEVENINGSTAR.c +++ b/src/ta_CDLEVENINGSTAR.c @@ -25,6 +25,38 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLEVENINGSTAR_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose, + SEXP optInPenetration +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + const double penetration = REAL(optInPenetration)[0]; + + // calculate lookback + const int lookback = TA_CDLEVENINGSTAR_Lookback(penetration); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLEVENINGSTAR( SEXP inOpen, diff --git a/src/ta_CDLGAPSIDESIDEWHITE.c b/src/ta_CDLGAPSIDESIDEWHITE.c index eaceff14..1a13ee90 100644 --- a/src/ta_CDLGAPSIDESIDEWHITE.c +++ b/src/ta_CDLGAPSIDESIDEWHITE.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLGAPSIDESIDEWHITE_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLGAPSIDESIDEWHITE_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLGAPSIDESIDEWHITE( SEXP inOpen, diff --git a/src/ta_CDLGRAVESTONEDOJI.c b/src/ta_CDLGRAVESTONEDOJI.c index fb73cf38..952100fc 100644 --- a/src/ta_CDLGRAVESTONEDOJI.c +++ b/src/ta_CDLGRAVESTONEDOJI.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLGRAVESTONEDOJI_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLGRAVESTONEDOJI_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLGRAVESTONEDOJI( SEXP inOpen, diff --git a/src/ta_CDLHAMMER.c b/src/ta_CDLHAMMER.c index 6f8ceba4..e361a610 100644 --- a/src/ta_CDLHAMMER.c +++ b/src/ta_CDLHAMMER.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLHAMMER_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLHAMMER_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLHAMMER( SEXP inOpen, diff --git a/src/ta_CDLHANGINGMAN.c b/src/ta_CDLHANGINGMAN.c index 87eea059..4e13daf3 100644 --- a/src/ta_CDLHANGINGMAN.c +++ b/src/ta_CDLHANGINGMAN.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLHANGINGMAN_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLHANGINGMAN_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLHANGINGMAN( SEXP inOpen, diff --git a/src/ta_CDLHARAMI.c b/src/ta_CDLHARAMI.c index 60ed602c..06511cf0 100644 --- a/src/ta_CDLHARAMI.c +++ b/src/ta_CDLHARAMI.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLHARAMI_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLHARAMI_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLHARAMI( SEXP inOpen, diff --git a/src/ta_CDLHARAMICROSS.c b/src/ta_CDLHARAMICROSS.c index e392cfbe..52bd8ae1 100644 --- a/src/ta_CDLHARAMICROSS.c +++ b/src/ta_CDLHARAMICROSS.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLHARAMICROSS_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLHARAMICROSS_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLHARAMICROSS( SEXP inOpen, diff --git a/src/ta_CDLHIGHWAVE.c b/src/ta_CDLHIGHWAVE.c index 9d1b0de9..8673192b 100644 --- a/src/ta_CDLHIGHWAVE.c +++ b/src/ta_CDLHIGHWAVE.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLHIGHWAVE_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLHIGHWAVE_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLHIGHWAVE( SEXP inOpen, diff --git a/src/ta_CDLHIKKAKE.c b/src/ta_CDLHIKKAKE.c index 5f70a053..22730af0 100644 --- a/src/ta_CDLHIKKAKE.c +++ b/src/ta_CDLHIKKAKE.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLHIKKAKE_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLHIKKAKE_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLHIKKAKE( SEXP inOpen, diff --git a/src/ta_CDLHIKKAKEMOD.c b/src/ta_CDLHIKKAKEMOD.c index d1a72194..611ff6b2 100644 --- a/src/ta_CDLHIKKAKEMOD.c +++ b/src/ta_CDLHIKKAKEMOD.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLHIKKAKEMOD_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLHIKKAKEMOD_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLHIKKAKEMOD( SEXP inOpen, diff --git a/src/ta_CDLHOMINGPIGEON.c b/src/ta_CDLHOMINGPIGEON.c index b26f446d..f6476ae7 100644 --- a/src/ta_CDLHOMINGPIGEON.c +++ b/src/ta_CDLHOMINGPIGEON.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLHOMINGPIGEON_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLHOMINGPIGEON_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLHOMINGPIGEON( SEXP inOpen, diff --git a/src/ta_CDLIDENTICAL3CROWS.c b/src/ta_CDLIDENTICAL3CROWS.c index 97aa530d..aa1f5a7e 100644 --- a/src/ta_CDLIDENTICAL3CROWS.c +++ b/src/ta_CDLIDENTICAL3CROWS.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLIDENTICAL3CROWS_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLIDENTICAL3CROWS_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLIDENTICAL3CROWS( SEXP inOpen, diff --git a/src/ta_CDLINNECK.c b/src/ta_CDLINNECK.c index e248af24..ae61db63 100644 --- a/src/ta_CDLINNECK.c +++ b/src/ta_CDLINNECK.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLINNECK_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLINNECK_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLINNECK( SEXP inOpen, diff --git a/src/ta_CDLINVERTEDHAMMER.c b/src/ta_CDLINVERTEDHAMMER.c index 66df1195..a640bf24 100644 --- a/src/ta_CDLINVERTEDHAMMER.c +++ b/src/ta_CDLINVERTEDHAMMER.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLINVERTEDHAMMER_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLINVERTEDHAMMER_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLINVERTEDHAMMER( SEXP inOpen, diff --git a/src/ta_CDLKICKING.c b/src/ta_CDLKICKING.c index 4bbad251..82be3804 100644 --- a/src/ta_CDLKICKING.c +++ b/src/ta_CDLKICKING.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLKICKING_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLKICKING_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLKICKING( SEXP inOpen, diff --git a/src/ta_CDLKICKINGBYLENGTH.c b/src/ta_CDLKICKINGBYLENGTH.c index f5f6faf8..7bb5aebb 100644 --- a/src/ta_CDLKICKINGBYLENGTH.c +++ b/src/ta_CDLKICKINGBYLENGTH.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLKICKINGBYLENGTH_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLKICKINGBYLENGTH_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLKICKINGBYLENGTH( SEXP inOpen, diff --git a/src/ta_CDLLADDERBOTTOM.c b/src/ta_CDLLADDERBOTTOM.c index 81b29ae4..458967b4 100644 --- a/src/ta_CDLLADDERBOTTOM.c +++ b/src/ta_CDLLADDERBOTTOM.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLLADDERBOTTOM_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLLADDERBOTTOM_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLLADDERBOTTOM( SEXP inOpen, diff --git a/src/ta_CDLLONGLEGGEDDOJI.c b/src/ta_CDLLONGLEGGEDDOJI.c index c1920a94..d5c764bd 100644 --- a/src/ta_CDLLONGLEGGEDDOJI.c +++ b/src/ta_CDLLONGLEGGEDDOJI.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLLONGLEGGEDDOJI_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLLONGLEGGEDDOJI_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLLONGLEGGEDDOJI( SEXP inOpen, diff --git a/src/ta_CDLLONGLINE.c b/src/ta_CDLLONGLINE.c index 577a53aa..d80d705c 100644 --- a/src/ta_CDLLONGLINE.c +++ b/src/ta_CDLLONGLINE.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLLONGLINE_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLLONGLINE_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLLONGLINE( SEXP inOpen, diff --git a/src/ta_CDLMARUBOZU.c b/src/ta_CDLMARUBOZU.c index 846bbf2d..683e7765 100644 --- a/src/ta_CDLMARUBOZU.c +++ b/src/ta_CDLMARUBOZU.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLMARUBOZU_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLMARUBOZU_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLMARUBOZU( SEXP inOpen, diff --git a/src/ta_CDLMATCHINGLOW.c b/src/ta_CDLMATCHINGLOW.c index 12cb8ff3..e9463130 100644 --- a/src/ta_CDLMATCHINGLOW.c +++ b/src/ta_CDLMATCHINGLOW.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLMATCHINGLOW_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLMATCHINGLOW_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLMATCHINGLOW( SEXP inOpen, diff --git a/src/ta_CDLMATHOLD.c b/src/ta_CDLMATHOLD.c index 7332f3f2..68860079 100644 --- a/src/ta_CDLMATHOLD.c +++ b/src/ta_CDLMATHOLD.c @@ -25,6 +25,38 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLMATHOLD_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose, + SEXP optInPenetration +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + const double penetration = REAL(optInPenetration)[0]; + + // calculate lookback + const int lookback = TA_CDLMATHOLD_Lookback(penetration); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLMATHOLD( SEXP inOpen, diff --git a/src/ta_CDLMORNINGDOJISTAR.c b/src/ta_CDLMORNINGDOJISTAR.c index dc621765..0083024f 100644 --- a/src/ta_CDLMORNINGDOJISTAR.c +++ b/src/ta_CDLMORNINGDOJISTAR.c @@ -25,6 +25,38 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLMORNINGDOJISTAR_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose, + SEXP optInPenetration +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + const double penetration = REAL(optInPenetration)[0]; + + // calculate lookback + const int lookback = TA_CDLMORNINGDOJISTAR_Lookback(penetration); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLMORNINGDOJISTAR( SEXP inOpen, diff --git a/src/ta_CDLMORNINGSTAR.c b/src/ta_CDLMORNINGSTAR.c index e08d3895..c0d2c97a 100644 --- a/src/ta_CDLMORNINGSTAR.c +++ b/src/ta_CDLMORNINGSTAR.c @@ -25,6 +25,38 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLMORNINGSTAR_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose, + SEXP optInPenetration +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + const double penetration = REAL(optInPenetration)[0]; + + // calculate lookback + const int lookback = TA_CDLMORNINGSTAR_Lookback(penetration); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLMORNINGSTAR( SEXP inOpen, diff --git a/src/ta_CDLONNECK.c b/src/ta_CDLONNECK.c index 3788cd92..3b3a7cdb 100644 --- a/src/ta_CDLONNECK.c +++ b/src/ta_CDLONNECK.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLONNECK_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLONNECK_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLONNECK( SEXP inOpen, diff --git a/src/ta_CDLPIERCING.c b/src/ta_CDLPIERCING.c index 8a8c150f..adf6bdaf 100644 --- a/src/ta_CDLPIERCING.c +++ b/src/ta_CDLPIERCING.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLPIERCING_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLPIERCING_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLPIERCING( SEXP inOpen, diff --git a/src/ta_CDLRICKSHAWMAN.c b/src/ta_CDLRICKSHAWMAN.c index de0c1401..7ddf2c6c 100644 --- a/src/ta_CDLRICKSHAWMAN.c +++ b/src/ta_CDLRICKSHAWMAN.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLRICKSHAWMAN_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLRICKSHAWMAN_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLRICKSHAWMAN( SEXP inOpen, diff --git a/src/ta_CDLRISEFALL3METHODS.c b/src/ta_CDLRISEFALL3METHODS.c index 7fdce1d5..0c55c09f 100644 --- a/src/ta_CDLRISEFALL3METHODS.c +++ b/src/ta_CDLRISEFALL3METHODS.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLRISEFALL3METHODS_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLRISEFALL3METHODS_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLRISEFALL3METHODS( SEXP inOpen, diff --git a/src/ta_CDLSEPARATINGLINES.c b/src/ta_CDLSEPARATINGLINES.c index 57d3820b..16bcc294 100644 --- a/src/ta_CDLSEPARATINGLINES.c +++ b/src/ta_CDLSEPARATINGLINES.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLSEPARATINGLINES_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLSEPARATINGLINES_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLSEPARATINGLINES( SEXP inOpen, diff --git a/src/ta_CDLSHOOTINGSTAR.c b/src/ta_CDLSHOOTINGSTAR.c index 9affb530..72b28e34 100644 --- a/src/ta_CDLSHOOTINGSTAR.c +++ b/src/ta_CDLSHOOTINGSTAR.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLSHOOTINGSTAR_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLSHOOTINGSTAR_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLSHOOTINGSTAR( SEXP inOpen, diff --git a/src/ta_CDLSHORTLINE.c b/src/ta_CDLSHORTLINE.c index a3e6f825..f9578a08 100644 --- a/src/ta_CDLSHORTLINE.c +++ b/src/ta_CDLSHORTLINE.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLSHORTLINE_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLSHORTLINE_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLSHORTLINE( SEXP inOpen, diff --git a/src/ta_CDLSPINNINGTOP.c b/src/ta_CDLSPINNINGTOP.c index 174122fe..c22c8c07 100644 --- a/src/ta_CDLSPINNINGTOP.c +++ b/src/ta_CDLSPINNINGTOP.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLSPINNINGTOP_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLSPINNINGTOP_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLSPINNINGTOP( SEXP inOpen, diff --git a/src/ta_CDLSTALLEDPATTERN.c b/src/ta_CDLSTALLEDPATTERN.c index 1f1932df..8172c2cb 100644 --- a/src/ta_CDLSTALLEDPATTERN.c +++ b/src/ta_CDLSTALLEDPATTERN.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLSTALLEDPATTERN_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLSTALLEDPATTERN_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLSTALLEDPATTERN( SEXP inOpen, diff --git a/src/ta_CDLSTICKSANDWICH.c b/src/ta_CDLSTICKSANDWICH.c index bfbf8faf..3f31a9b3 100644 --- a/src/ta_CDLSTICKSANDWICH.c +++ b/src/ta_CDLSTICKSANDWICH.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLSTICKSANDWICH_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLSTICKSANDWICH_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLSTICKSANDWICH( SEXP inOpen, diff --git a/src/ta_CDLTAKURI.c b/src/ta_CDLTAKURI.c index bbc4b406..b537a384 100644 --- a/src/ta_CDLTAKURI.c +++ b/src/ta_CDLTAKURI.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLTAKURI_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLTAKURI_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLTAKURI( SEXP inOpen, diff --git a/src/ta_CDLTASUKIGAP.c b/src/ta_CDLTASUKIGAP.c index b4f3a7f0..dc3ec6a3 100644 --- a/src/ta_CDLTASUKIGAP.c +++ b/src/ta_CDLTASUKIGAP.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLTASUKIGAP_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLTASUKIGAP_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLTASUKIGAP( SEXP inOpen, diff --git a/src/ta_CDLTHRUSTING.c b/src/ta_CDLTHRUSTING.c index 1518ce8e..c01151b7 100644 --- a/src/ta_CDLTHRUSTING.c +++ b/src/ta_CDLTHRUSTING.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLTHRUSTING_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLTHRUSTING_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLTHRUSTING( SEXP inOpen, diff --git a/src/ta_CDLTRISTAR.c b/src/ta_CDLTRISTAR.c index 974f9b78..1c0d841f 100644 --- a/src/ta_CDLTRISTAR.c +++ b/src/ta_CDLTRISTAR.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLTRISTAR_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLTRISTAR_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLTRISTAR( SEXP inOpen, diff --git a/src/ta_CDLUNIQUE3RIVER.c b/src/ta_CDLUNIQUE3RIVER.c index d48f9220..d77b621d 100644 --- a/src/ta_CDLUNIQUE3RIVER.c +++ b/src/ta_CDLUNIQUE3RIVER.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLUNIQUE3RIVER_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLUNIQUE3RIVER_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLUNIQUE3RIVER( SEXP inOpen, diff --git a/src/ta_CDLUPSIDEGAP2CROWS.c b/src/ta_CDLUPSIDEGAP2CROWS.c index 1fa4e148..bf86240a 100644 --- a/src/ta_CDLUPSIDEGAP2CROWS.c +++ b/src/ta_CDLUPSIDEGAP2CROWS.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLUPSIDEGAP2CROWS_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLUPSIDEGAP2CROWS_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLUPSIDEGAP2CROWS( SEXP inOpen, diff --git a/src/ta_CDLXSIDEGAP3METHODS.c b/src/ta_CDLXSIDEGAP3METHODS.c index 0b988b8f..8b045aa5 100644 --- a/src/ta_CDLXSIDEGAP3METHODS.c +++ b/src/ta_CDLXSIDEGAP3METHODS.c @@ -24,6 +24,35 @@ #include "shift.h" #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CDLXSIDEGAP3METHODS_lookback( + SEXP inOpen, + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // pointers to input + const double *open_ptr = REAL(inOpen); + const double *high_ptr = REAL(inHigh); + const double *low_ptr = REAL(inLow); + const double *close_ptr = REAL(inClose); + int n = LENGTH(inOpen); + + // calculate lookback + const int lookback = TA_CDLXSIDEGAP3METHODS_Lookback(); + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + + return output; +} + // clang-format off SEXP impl_ta_CDLXSIDEGAP3METHODS( SEXP inOpen, diff --git a/src/ta_CMO.c b/src/ta_CMO.c index c1dc4969..edcf9a95 100644 --- a/src/ta_CMO.c +++ b/src/ta_CMO.c @@ -22,6 +22,36 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CMO_lookback( + SEXP inReal, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_CMO_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_CMO( SEXP inReal, diff --git a/src/ta_CORREL.c b/src/ta_CORREL.c index 08476bee..06a33d42 100644 --- a/src/ta_CORREL.c +++ b/src/ta_CORREL.c @@ -23,6 +23,38 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_CORREL_lookback( + SEXP inReal0, + SEXP inReal1, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inReal0' (assumes equal length across input) + int n = LENGTH(inReal0); + + // pointers to input arrays + const double *inReal0_ptr = REAL(inReal0); + const double *inReal1_ptr = REAL(inReal1); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_CORREL_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_CORREL( SEXP inReal0, diff --git a/src/ta_DEMA.c b/src/ta_DEMA.c index b56cd536..5a9fc112 100644 --- a/src/ta_DEMA.c +++ b/src/ta_DEMA.c @@ -22,6 +22,36 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_DEMA_lookback( + SEXP inReal, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_DEMA_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_DEMA( SEXP inReal, diff --git a/src/ta_DX.c b/src/ta_DX.c index a031498b..5c9b12f4 100644 --- a/src/ta_DX.c +++ b/src/ta_DX.c @@ -24,6 +24,40 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_DX_lookback( + SEXP inHigh, + SEXP inLow, + SEXP inClose, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inHigh' (assumes equal length across input) + int n = LENGTH(inHigh); + + // pointers to input arrays + const double *inHigh_ptr = REAL(inHigh); + const double *inLow_ptr = REAL(inLow); + const double *inClose_ptr = REAL(inClose); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_DX_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_DX( SEXP inHigh, diff --git a/src/ta_EMA.c b/src/ta_EMA.c index 02067a54..321f100d 100644 --- a/src/ta_EMA.c +++ b/src/ta_EMA.c @@ -22,6 +22,36 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_EMA_lookback( + SEXP inReal, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_EMA_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_EMA( SEXP inReal, diff --git a/src/ta_HT_DCPERIOD.c b/src/ta_HT_DCPERIOD.c index 3d72afc4..770af802 100644 --- a/src/ta_HT_DCPERIOD.c +++ b/src/ta_HT_DCPERIOD.c @@ -21,6 +21,32 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_HT_DCPERIOD_lookback( + SEXP inReal +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // calculate lookback + const int lookback = TA_HT_DCPERIOD_Lookback(); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_HT_DCPERIOD( SEXP inReal, diff --git a/src/ta_HT_DCPHASE.c b/src/ta_HT_DCPHASE.c index a05c7abd..23461b58 100644 --- a/src/ta_HT_DCPHASE.c +++ b/src/ta_HT_DCPHASE.c @@ -21,6 +21,32 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_HT_DCPHASE_lookback( + SEXP inReal +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // calculate lookback + const int lookback = TA_HT_DCPHASE_Lookback(); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_HT_DCPHASE( SEXP inReal, diff --git a/src/ta_HT_PHASOR.c b/src/ta_HT_PHASOR.c index 2d73a485..870af586 100644 --- a/src/ta_HT_PHASOR.c +++ b/src/ta_HT_PHASOR.c @@ -21,6 +21,32 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_HT_PHASOR_lookback( + SEXP inReal +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // calculate lookback + const int lookback = TA_HT_PHASOR_Lookback(); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_HT_PHASOR( SEXP inReal, diff --git a/src/ta_HT_SINE.c b/src/ta_HT_SINE.c index fe50ba65..2adcfa2b 100644 --- a/src/ta_HT_SINE.c +++ b/src/ta_HT_SINE.c @@ -21,6 +21,32 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_HT_SINE_lookback( + SEXP inReal +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // calculate lookback + const int lookback = TA_HT_SINE_Lookback(); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_HT_SINE( SEXP inReal, diff --git a/src/ta_HT_TRENDLINE.c b/src/ta_HT_TRENDLINE.c index 3a05c0f3..5a501f5e 100644 --- a/src/ta_HT_TRENDLINE.c +++ b/src/ta_HT_TRENDLINE.c @@ -21,6 +21,32 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_HT_TRENDLINE_lookback( + SEXP inReal +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // calculate lookback + const int lookback = TA_HT_TRENDLINE_Lookback(); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_HT_TRENDLINE( SEXP inReal, diff --git a/src/ta_HT_TRENDMODE.c b/src/ta_HT_TRENDMODE.c index 62eaa65c..e5d02526 100644 --- a/src/ta_HT_TRENDMODE.c +++ b/src/ta_HT_TRENDMODE.c @@ -21,6 +21,32 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_HT_TRENDMODE_lookback( + SEXP inReal +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // calculate lookback + const int lookback = TA_HT_TRENDMODE_Lookback(); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_HT_TRENDMODE( SEXP inReal, diff --git a/src/ta_IMI.c b/src/ta_IMI.c index 10eff293..457b81d7 100644 --- a/src/ta_IMI.c +++ b/src/ta_IMI.c @@ -23,6 +23,38 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_IMI_lookback( + SEXP inOpen, + SEXP inClose, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inOpen' (assumes equal length across input) + int n = LENGTH(inOpen); + + // pointers to input arrays + const double *inOpen_ptr = REAL(inOpen); + const double *inClose_ptr = REAL(inClose); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_IMI_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_IMI( SEXP inOpen, diff --git a/src/ta_KAMA.c b/src/ta_KAMA.c index bc7ce471..b2d001d3 100644 --- a/src/ta_KAMA.c +++ b/src/ta_KAMA.c @@ -22,6 +22,36 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_KAMA_lookback( + SEXP inReal, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_KAMA_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_KAMA( SEXP inReal, diff --git a/src/ta_MACD.c b/src/ta_MACD.c index df86ecc4..2bcdb717 100644 --- a/src/ta_MACD.c +++ b/src/ta_MACD.c @@ -24,6 +24,43 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_MACD_lookback( + SEXP inReal, + SEXP optInFastPeriod, + SEXP optInSlowPeriod, + SEXP optInSignalPeriod +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // extract input values + const int optInFastPeriod_value = INTEGER(optInFastPeriod)[0]; + const int optInSlowPeriod_value = INTEGER(optInSlowPeriod)[0]; + const int optInSignalPeriod_value = INTEGER(optInSignalPeriod)[0]; + + // calculate lookback + const int lookback = TA_MACD_Lookback( + optInFastPeriod_value, + optInSlowPeriod_value, + optInSignalPeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_MACD( SEXP inReal, diff --git a/src/ta_MACDEXT.c b/src/ta_MACDEXT.c index 275176b6..2c797183 100644 --- a/src/ta_MACDEXT.c +++ b/src/ta_MACDEXT.c @@ -27,6 +27,52 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_MACDEXT_lookback( + SEXP inReal, + SEXP optInFastPeriod, + SEXP optInFastMAType, + SEXP optInSlowPeriod, + SEXP optInSlowMAType, + SEXP optInSignalPeriod, + SEXP optInSignalMAType +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // extract input values + const int optInFastPeriod_value = INTEGER(optInFastPeriod)[0]; + const TA_MAType optInFastMAType_value = as_MAType(optInFastMAType); + const int optInSlowPeriod_value = INTEGER(optInSlowPeriod)[0]; + const TA_MAType optInSlowMAType_value = as_MAType(optInSlowMAType); + const int optInSignalPeriod_value = INTEGER(optInSignalPeriod)[0]; + const TA_MAType optInSignalMAType_value = as_MAType(optInSignalMAType); + + // calculate lookback + const int lookback = TA_MACDEXT_Lookback( + optInFastPeriod_value, + optInFastMAType_value, + optInSlowPeriod_value, + optInSlowMAType_value, + optInSignalPeriod_value, + optInSignalMAType_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_MACDEXT( SEXP inReal, diff --git a/src/ta_MACDFIX.c b/src/ta_MACDFIX.c index f34ce64b..0bdfc030 100644 --- a/src/ta_MACDFIX.c +++ b/src/ta_MACDFIX.c @@ -22,6 +22,36 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_MACDFIX_lookback( + SEXP inReal, + SEXP optInSignalPeriod +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // extract input values + const int optInSignalPeriod_value = INTEGER(optInSignalPeriod)[0]; + + // calculate lookback + const int lookback = TA_MACDFIX_Lookback(optInSignalPeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_MACDFIX( SEXP inReal, diff --git a/src/ta_MAMA.c b/src/ta_MAMA.c index e8011f61..42dc17b6 100644 --- a/src/ta_MAMA.c +++ b/src/ta_MAMA.c @@ -23,6 +23,39 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_MAMA_lookback( + SEXP inReal, + SEXP optInFastLimit, + SEXP optInSlowLimit +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // extract input values + const double optInFastLimit_value = REAL(optInFastLimit)[0]; + const double optInSlowLimit_value = REAL(optInSlowLimit)[0]; + + // calculate lookback + const int lookback = + TA_MAMA_Lookback(optInFastLimit_value, optInSlowLimit_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_MAMA( SEXP inReal, diff --git a/src/ta_MAX.c b/src/ta_MAX.c index 6ab70ef6..a255679d 100644 --- a/src/ta_MAX.c +++ b/src/ta_MAX.c @@ -22,6 +22,36 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_MAX_lookback( + SEXP inReal, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_MAX_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_MAX( SEXP inReal, diff --git a/src/ta_MEDPRICE.c b/src/ta_MEDPRICE.c index 26f61945..e2030616 100644 --- a/src/ta_MEDPRICE.c +++ b/src/ta_MEDPRICE.c @@ -22,6 +22,34 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_MEDPRICE_lookback( + SEXP inHigh, + SEXP inLow +) +// clang-format on +{ + // values + // get length of 'inHigh' (assumes equal length across input) + int n = LENGTH(inHigh); + + // pointers to input arrays + const double *inHigh_ptr = REAL(inHigh); + const double *inLow_ptr = REAL(inLow); + + // calculate lookback + const int lookback = TA_MEDPRICE_Lookback(); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_MEDPRICE( SEXP inHigh, diff --git a/src/ta_MFI.c b/src/ta_MFI.c index f5e10241..3f8e20c0 100644 --- a/src/ta_MFI.c +++ b/src/ta_MFI.c @@ -25,6 +25,42 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_MFI_lookback( + SEXP inHigh, + SEXP inLow, + SEXP inClose, + SEXP inVolume, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inHigh' (assumes equal length across input) + int n = LENGTH(inHigh); + + // pointers to input arrays + const double *inHigh_ptr = REAL(inHigh); + const double *inLow_ptr = REAL(inLow); + const double *inClose_ptr = REAL(inClose); + const double *inVolume_ptr = REAL(inVolume); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_MFI_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_MFI( SEXP inHigh, diff --git a/src/ta_MIDPRICE.c b/src/ta_MIDPRICE.c index defbb2ca..03f676ce 100644 --- a/src/ta_MIDPRICE.c +++ b/src/ta_MIDPRICE.c @@ -23,6 +23,38 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_MIDPRICE_lookback( + SEXP inHigh, + SEXP inLow, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inHigh' (assumes equal length across input) + int n = LENGTH(inHigh); + + // pointers to input arrays + const double *inHigh_ptr = REAL(inHigh); + const double *inLow_ptr = REAL(inLow); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_MIDPRICE_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_MIDPRICE( SEXP inHigh, diff --git a/src/ta_MIN.c b/src/ta_MIN.c index 89a124f6..1e72c98d 100644 --- a/src/ta_MIN.c +++ b/src/ta_MIN.c @@ -22,6 +22,36 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_MIN_lookback( + SEXP inReal, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_MIN_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_MIN( SEXP inReal, diff --git a/src/ta_MINUS_DI.c b/src/ta_MINUS_DI.c index ae883d4a..df8be017 100644 --- a/src/ta_MINUS_DI.c +++ b/src/ta_MINUS_DI.c @@ -24,6 +24,40 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_MINUS_DI_lookback( + SEXP inHigh, + SEXP inLow, + SEXP inClose, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inHigh' (assumes equal length across input) + int n = LENGTH(inHigh); + + // pointers to input arrays + const double *inHigh_ptr = REAL(inHigh); + const double *inLow_ptr = REAL(inLow); + const double *inClose_ptr = REAL(inClose); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_MINUS_DI_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_MINUS_DI( SEXP inHigh, diff --git a/src/ta_MINUS_DM.c b/src/ta_MINUS_DM.c index 29c65c0d..2f252234 100644 --- a/src/ta_MINUS_DM.c +++ b/src/ta_MINUS_DM.c @@ -23,6 +23,38 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_MINUS_DM_lookback( + SEXP inHigh, + SEXP inLow, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inHigh' (assumes equal length across input) + int n = LENGTH(inHigh); + + // pointers to input arrays + const double *inHigh_ptr = REAL(inHigh); + const double *inLow_ptr = REAL(inLow); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_MINUS_DM_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_MINUS_DM( SEXP inHigh, diff --git a/src/ta_MOM.c b/src/ta_MOM.c index b381fb6a..be3793ed 100644 --- a/src/ta_MOM.c +++ b/src/ta_MOM.c @@ -22,6 +22,36 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_MOM_lookback( + SEXP inReal, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_MOM_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_MOM( SEXP inReal, diff --git a/src/ta_NATR.c b/src/ta_NATR.c index 776aa984..1de11713 100644 --- a/src/ta_NATR.c +++ b/src/ta_NATR.c @@ -24,6 +24,40 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_NATR_lookback( + SEXP inHigh, + SEXP inLow, + SEXP inClose, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inHigh' (assumes equal length across input) + int n = LENGTH(inHigh); + + // pointers to input arrays + const double *inHigh_ptr = REAL(inHigh); + const double *inLow_ptr = REAL(inLow); + const double *inClose_ptr = REAL(inClose); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_NATR_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_NATR( SEXP inHigh, diff --git a/src/ta_OBV.c b/src/ta_OBV.c index af8cc377..fa492f17 100644 --- a/src/ta_OBV.c +++ b/src/ta_OBV.c @@ -22,6 +22,34 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_OBV_lookback( + SEXP inReal, + SEXP inVolume +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + const double *inVolume_ptr = REAL(inVolume); + + // calculate lookback + const int lookback = TA_OBV_Lookback(); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_OBV( SEXP inReal, diff --git a/src/ta_PLUS_DI.c b/src/ta_PLUS_DI.c index ee1ebdd1..233b0b23 100644 --- a/src/ta_PLUS_DI.c +++ b/src/ta_PLUS_DI.c @@ -24,6 +24,40 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_PLUS_DI_lookback( + SEXP inHigh, + SEXP inLow, + SEXP inClose, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inHigh' (assumes equal length across input) + int n = LENGTH(inHigh); + + // pointers to input arrays + const double *inHigh_ptr = REAL(inHigh); + const double *inLow_ptr = REAL(inLow); + const double *inClose_ptr = REAL(inClose); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_PLUS_DI_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_PLUS_DI( SEXP inHigh, diff --git a/src/ta_PLUS_DM.c b/src/ta_PLUS_DM.c index 61bebf77..199c6094 100644 --- a/src/ta_PLUS_DM.c +++ b/src/ta_PLUS_DM.c @@ -23,6 +23,38 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_PLUS_DM_lookback( + SEXP inHigh, + SEXP inLow, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inHigh' (assumes equal length across input) + int n = LENGTH(inHigh); + + // pointers to input arrays + const double *inHigh_ptr = REAL(inHigh); + const double *inLow_ptr = REAL(inLow); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_PLUS_DM_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_PLUS_DM( SEXP inHigh, diff --git a/src/ta_PPO.c b/src/ta_PPO.c index d4bee26f..a21d8ca7 100644 --- a/src/ta_PPO.c +++ b/src/ta_PPO.c @@ -24,6 +24,43 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_PPO_lookback( + SEXP inReal, + SEXP optInFastPeriod, + SEXP optInSlowPeriod, + SEXP optInMAType +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // extract input values + const int optInFastPeriod_value = INTEGER(optInFastPeriod)[0]; + const int optInSlowPeriod_value = INTEGER(optInSlowPeriod)[0]; + const TA_MAType optInMAType_value = as_MAType(optInMAType); + + // calculate lookback + const int lookback = TA_PPO_Lookback( + optInFastPeriod_value, + optInSlowPeriod_value, + optInMAType_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_PPO( SEXP inReal, diff --git a/src/ta_ROC.c b/src/ta_ROC.c index 74e62e7e..9039fc03 100644 --- a/src/ta_ROC.c +++ b/src/ta_ROC.c @@ -22,6 +22,36 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_ROC_lookback( + SEXP inReal, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_ROC_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_ROC( SEXP inReal, diff --git a/src/ta_ROCR.c b/src/ta_ROCR.c index b6f4ac3d..e9992542 100644 --- a/src/ta_ROCR.c +++ b/src/ta_ROCR.c @@ -22,6 +22,36 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_ROCR_lookback( + SEXP inReal, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_ROCR_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_ROCR( SEXP inReal, diff --git a/src/ta_RSI.c b/src/ta_RSI.c index 52f36183..7c32fdfb 100644 --- a/src/ta_RSI.c +++ b/src/ta_RSI.c @@ -22,6 +22,36 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_RSI_lookback( + SEXP inReal, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_RSI_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_RSI( SEXP inReal, diff --git a/src/ta_SAR.c b/src/ta_SAR.c index db52561a..899f5a3e 100644 --- a/src/ta_SAR.c +++ b/src/ta_SAR.c @@ -24,6 +24,41 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_SAR_lookback( + SEXP inHigh, + SEXP inLow, + SEXP optInAcceleration, + SEXP optInMaximum +) +// clang-format on +{ + // values + // get length of 'inHigh' (assumes equal length across input) + int n = LENGTH(inHigh); + + // pointers to input arrays + const double *inHigh_ptr = REAL(inHigh); + const double *inLow_ptr = REAL(inLow); + + // extract input values + const double optInAcceleration_value = REAL(optInAcceleration)[0]; + const double optInMaximum_value = REAL(optInMaximum)[0]; + + // calculate lookback + const int lookback = + TA_SAR_Lookback(optInAcceleration_value, optInMaximum_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_SAR( SEXP inHigh, diff --git a/src/ta_SAREXT.c b/src/ta_SAREXT.c index d208e886..e5ddfe44 100644 --- a/src/ta_SAREXT.c +++ b/src/ta_SAREXT.c @@ -30,6 +30,64 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_SAREXT_lookback( + SEXP inHigh, + SEXP inLow, + SEXP optInStartValue, + SEXP optInOffsetOnReverse, + SEXP optInAccelerationInitLong, + SEXP optInAccelerationLong, + SEXP optInAccelerationMaxLong, + SEXP optInAccelerationInitShort, + SEXP optInAccelerationShort, + SEXP optInAccelerationMaxShort +) +// clang-format on +{ + // values + // get length of 'inHigh' (assumes equal length across input) + int n = LENGTH(inHigh); + + // pointers to input arrays + const double *inHigh_ptr = REAL(inHigh); + const double *inLow_ptr = REAL(inLow); + + // extract input values + const double optInStartValue_value = REAL(optInStartValue)[0]; + const double optInOffsetOnReverse_value = REAL(optInOffsetOnReverse)[0]; + const double optInAccelerationInitLong_value = + REAL(optInAccelerationInitLong)[0]; + const double optInAccelerationLong_value = REAL(optInAccelerationLong)[0]; + const double optInAccelerationMaxLong_value = + REAL(optInAccelerationMaxLong)[0]; + const double optInAccelerationInitShort_value = + REAL(optInAccelerationInitShort)[0]; + const double optInAccelerationShort_value = REAL(optInAccelerationShort)[0]; + const double optInAccelerationMaxShort_value = + REAL(optInAccelerationMaxShort)[0]; + + // calculate lookback + const int lookback = TA_SAREXT_Lookback( + optInStartValue_value, + optInOffsetOnReverse_value, + optInAccelerationInitLong_value, + optInAccelerationLong_value, + optInAccelerationMaxLong_value, + optInAccelerationInitShort_value, + optInAccelerationShort_value, + optInAccelerationMaxShort_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_SAREXT( SEXP inHigh, diff --git a/src/ta_SMA.c b/src/ta_SMA.c index 5c0f2ee2..f2658723 100644 --- a/src/ta_SMA.c +++ b/src/ta_SMA.c @@ -22,6 +22,36 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_SMA_lookback( + SEXP inReal, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_SMA_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_SMA( SEXP inReal, diff --git a/src/ta_STDDEV.c b/src/ta_STDDEV.c index 8849d5c3..58b13183 100644 --- a/src/ta_STDDEV.c +++ b/src/ta_STDDEV.c @@ -23,6 +23,39 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_STDDEV_lookback( + SEXP inReal, + SEXP optInTimePeriod, + SEXP optInNbDev +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + const double optInNbDev_value = REAL(optInNbDev)[0]; + + // calculate lookback + const int lookback = + TA_STDDEV_Lookback(optInTimePeriod_value, optInNbDev_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_STDDEV( SEXP inReal, diff --git a/src/ta_STOCH.c b/src/ta_STOCH.c index 6d0a3dab..d01551d6 100644 --- a/src/ta_STOCH.c +++ b/src/ta_STOCH.c @@ -28,6 +28,53 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_STOCH_lookback( + SEXP inHigh, + SEXP inLow, + SEXP inClose, + SEXP optInFastK_Period, + SEXP optInSlowK_Period, + SEXP optInSlowK_MAType, + SEXP optInSlowD_Period, + SEXP optInSlowD_MAType +) +// clang-format on +{ + // values + // get length of 'inHigh' (assumes equal length across input) + int n = LENGTH(inHigh); + + // pointers to input arrays + const double *inHigh_ptr = REAL(inHigh); + const double *inLow_ptr = REAL(inLow); + const double *inClose_ptr = REAL(inClose); + + // extract input values + const int optInFastK_Period_value = INTEGER(optInFastK_Period)[0]; + const int optInSlowK_Period_value = INTEGER(optInSlowK_Period)[0]; + const TA_MAType optInSlowK_MAType_value = as_MAType(optInSlowK_MAType); + const int optInSlowD_Period_value = INTEGER(optInSlowD_Period)[0]; + const TA_MAType optInSlowD_MAType_value = as_MAType(optInSlowD_MAType); + + // calculate lookback + const int lookback = TA_STOCH_Lookback( + optInFastK_Period_value, + optInSlowK_Period_value, + optInSlowK_MAType_value, + optInSlowD_Period_value, + optInSlowD_MAType_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_STOCH( SEXP inHigh, diff --git a/src/ta_STOCHF.c b/src/ta_STOCHF.c index 45411baa..c66a8229 100644 --- a/src/ta_STOCHF.c +++ b/src/ta_STOCHF.c @@ -26,6 +26,47 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_STOCHF_lookback( + SEXP inHigh, + SEXP inLow, + SEXP inClose, + SEXP optInFastK_Period, + SEXP optInFastD_Period, + SEXP optInFastD_MAType +) +// clang-format on +{ + // values + // get length of 'inHigh' (assumes equal length across input) + int n = LENGTH(inHigh); + + // pointers to input arrays + const double *inHigh_ptr = REAL(inHigh); + const double *inLow_ptr = REAL(inLow); + const double *inClose_ptr = REAL(inClose); + + // extract input values + const int optInFastK_Period_value = INTEGER(optInFastK_Period)[0]; + const int optInFastD_Period_value = INTEGER(optInFastD_Period)[0]; + const TA_MAType optInFastD_MAType_value = as_MAType(optInFastD_MAType); + + // calculate lookback + const int lookback = TA_STOCHF_Lookback( + optInFastK_Period_value, + optInFastD_Period_value, + optInFastD_MAType_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_STOCHF( SEXP inHigh, diff --git a/src/ta_STOCHRSI.c b/src/ta_STOCHRSI.c index 3f372b33..7422b851 100644 --- a/src/ta_STOCHRSI.c +++ b/src/ta_STOCHRSI.c @@ -25,6 +25,46 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_STOCHRSI_lookback( + SEXP inReal, + SEXP optInTimePeriod, + SEXP optInFastK_Period, + SEXP optInFastD_Period, + SEXP optInFastD_MAType +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + const int optInFastK_Period_value = INTEGER(optInFastK_Period)[0]; + const int optInFastD_Period_value = INTEGER(optInFastD_Period)[0]; + const TA_MAType optInFastD_MAType_value = as_MAType(optInFastD_MAType); + + // calculate lookback + const int lookback = TA_STOCHRSI_Lookback( + optInTimePeriod_value, + optInFastK_Period_value, + optInFastD_Period_value, + optInFastD_MAType_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_STOCHRSI( SEXP inReal, diff --git a/src/ta_SUM.c b/src/ta_SUM.c index e6311185..4b1199b5 100644 --- a/src/ta_SUM.c +++ b/src/ta_SUM.c @@ -22,6 +22,36 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_SUM_lookback( + SEXP inReal, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_SUM_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_SUM( SEXP inReal, diff --git a/src/ta_T3.c b/src/ta_T3.c index 7b1693b8..f92c9235 100644 --- a/src/ta_T3.c +++ b/src/ta_T3.c @@ -23,6 +23,39 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_T3_lookback( + SEXP inReal, + SEXP optInTimePeriod, + SEXP optInVFactor +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + const double optInVFactor_value = REAL(optInVFactor)[0]; + + // calculate lookback + const int lookback = + TA_T3_Lookback(optInTimePeriod_value, optInVFactor_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_T3( SEXP inReal, diff --git a/src/ta_TEMA.c b/src/ta_TEMA.c index e51ddd0f..6375382e 100644 --- a/src/ta_TEMA.c +++ b/src/ta_TEMA.c @@ -22,6 +22,36 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_TEMA_lookback( + SEXP inReal, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_TEMA_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_TEMA( SEXP inReal, diff --git a/src/ta_TRANGE.c b/src/ta_TRANGE.c index 1baf5843..b1dac959 100644 --- a/src/ta_TRANGE.c +++ b/src/ta_TRANGE.c @@ -23,6 +23,36 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_TRANGE_lookback( + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // values + // get length of 'inHigh' (assumes equal length across input) + int n = LENGTH(inHigh); + + // pointers to input arrays + const double *inHigh_ptr = REAL(inHigh); + const double *inLow_ptr = REAL(inLow); + const double *inClose_ptr = REAL(inClose); + + // calculate lookback + const int lookback = TA_TRANGE_Lookback(); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_TRANGE( SEXP inHigh, diff --git a/src/ta_TRIMA.c b/src/ta_TRIMA.c index 2439b6db..65c5305d 100644 --- a/src/ta_TRIMA.c +++ b/src/ta_TRIMA.c @@ -22,6 +22,36 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_TRIMA_lookback( + SEXP inReal, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_TRIMA_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_TRIMA( SEXP inReal, diff --git a/src/ta_TRIX.c b/src/ta_TRIX.c index 36db4404..670e60a0 100644 --- a/src/ta_TRIX.c +++ b/src/ta_TRIX.c @@ -22,6 +22,36 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_TRIX_lookback( + SEXP inReal, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_TRIX_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_TRIX( SEXP inReal, diff --git a/src/ta_TYPPRICE.c b/src/ta_TYPPRICE.c index 68f6bb87..b548c22f 100644 --- a/src/ta_TYPPRICE.c +++ b/src/ta_TYPPRICE.c @@ -23,6 +23,36 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_TYPPRICE_lookback( + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // values + // get length of 'inHigh' (assumes equal length across input) + int n = LENGTH(inHigh); + + // pointers to input arrays + const double *inHigh_ptr = REAL(inHigh); + const double *inLow_ptr = REAL(inLow); + const double *inClose_ptr = REAL(inClose); + + // calculate lookback + const int lookback = TA_TYPPRICE_Lookback(); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_TYPPRICE( SEXP inHigh, diff --git a/src/ta_ULTOSC.c b/src/ta_ULTOSC.c index f8d7b834..27316c14 100644 --- a/src/ta_ULTOSC.c +++ b/src/ta_ULTOSC.c @@ -26,6 +26,47 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_ULTOSC_lookback( + SEXP inHigh, + SEXP inLow, + SEXP inClose, + SEXP optInTimePeriod1, + SEXP optInTimePeriod2, + SEXP optInTimePeriod3 +) +// clang-format on +{ + // values + // get length of 'inHigh' (assumes equal length across input) + int n = LENGTH(inHigh); + + // pointers to input arrays + const double *inHigh_ptr = REAL(inHigh); + const double *inLow_ptr = REAL(inLow); + const double *inClose_ptr = REAL(inClose); + + // extract input values + const int optInTimePeriod1_value = INTEGER(optInTimePeriod1)[0]; + const int optInTimePeriod2_value = INTEGER(optInTimePeriod2)[0]; + const int optInTimePeriod3_value = INTEGER(optInTimePeriod3)[0]; + + // calculate lookback + const int lookback = TA_ULTOSC_Lookback( + optInTimePeriod1_value, + optInTimePeriod2_value, + optInTimePeriod3_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_ULTOSC( SEXP inHigh, diff --git a/src/ta_VAR.c b/src/ta_VAR.c index 7a4a863a..ebf3d680 100644 --- a/src/ta_VAR.c +++ b/src/ta_VAR.c @@ -23,6 +23,38 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_VAR_lookback( + SEXP inReal, + SEXP optInTimePeriod, + SEXP optInNbDev +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + const double optInNbDev_value = REAL(optInNbDev)[0]; + + // calculate lookback + const int lookback = TA_VAR_Lookback(optInTimePeriod_value, optInNbDev_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_VAR( SEXP inReal, diff --git a/src/ta_VOLUME.c b/src/ta_VOLUME.c index 2a631aa0..21591773 100644 --- a/src/ta_VOLUME.c +++ b/src/ta_VOLUME.c @@ -1,14 +1,20 @@ // ta_VOLUME.c // // Parameters -// double inReal -// list maSpec (each element is integer(2): c(period, maType)) +// double inReal +// list maSpec (each element is integer(2): c(period, maType)) +// logical na_rm // // Returns // matrix (n x (1 + length(maSpec))) with columns: // "VOLUME", "" e.g. "SMA7" // +// The "lookback" attribute is the maximum lookback across all maSpec +// entries, and 0 when no maSpec is supplied. The "VOLUME" column itself +// always has a lookback of 0. +// #include "MAType.h" +#include "attributes.h" #include "container.h" #include "lib.h" #include "na.h" @@ -20,6 +26,37 @@ #include #include +// the lookback function is exported as a standalone function for downstream +// wrappers. 'inReal' is unused but kept for call-signature parity with +// impl_ta_VOLUME +// clang-format off +SEXP impl_ta_VOLUME_lookback( + SEXP inReal, + SEXP maSpec +) +// clang-format on +{ + (void)inReal; + + const int n_ma = isNull(maSpec) ? 0 : LENGTH(maSpec); + + // maximum lookback across all maSpec entries (stays 0 when none supplied) + int lookback = 0; + for (int j = 0; j < n_ma; ++j) { + // each specification is integer(2): c(period, maType) + const int *spec = INTEGER(VECTOR_ELT(maSpec, j)); + const int ma_lookback = TA_MA_Lookback(spec[0], (TA_MAType)spec[1]); + if (ma_lookback > lookback) { + lookback = ma_lookback; + } + } + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_VOLUME( SEXP inReal, @@ -45,55 +82,55 @@ SEXP impl_ta_VOLUME( const double *na_arrays[] = {x}; n = build_na_mask(na_mask, n, 1, na_arrays); if (n < n_original) { - double *compact_0 = (double *)R_alloc(n, sizeof(double)); - compact_array(compact_0, x, na_mask, n_original); - x = compact_0; + compact_arrays(na_arrays, 1, na_mask, n_original, n); + x = na_arrays[0]; } else { na_mask = NULL; } } - // determine maSpec input + // one column for 'VOLUME' plus one per moving average const int n_ma = isNull(maSpec) ? 0 : LENGTH(maSpec); const int n_cols = 1 + n_ma; - // output + // the output container is either an INTSXP or REALSXP and returns a + // matrix of on a lookback mismatch - the 'VOLUME' column is always + // valid, so the container lookback is 0 + // see container.h for more details SEXP output; double *output_ptr; - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details output_container(n, 0, n_cols, &output, &output_ptr, &protection_count); + + // first column is the (NA-compacted) volume itself memcpy(output_ptr, x, (size_t)n * sizeof(double)); - // set initial column name + // column names: "VOLUME" followed by "" const char **colname = (const char **)R_alloc((size_t)n_cols, sizeof(*colname)); colname[0] = "VOLUME"; - // iterate over maSpec - for (int j = 0; j < n_ma; ++j) { - int start_idx = 0; - int end_idx = 0; + // maximum lookback across all maSpec entries (stays 0 when none supplied) + int lookback = 0; - // extract maSpec - // - // specification is a downstream enum - // period is passed in the downstream enum - SEXP specification = VECTOR_ELT(maSpec, j); - const int *specification_ptr = INTEGER(specification); + for (int j = 0; j < n_ma; ++j) { + // each specification is integer(2): c(period, maType) + const int *spec = INTEGER(VECTOR_ELT(maSpec, j)); + const int period = spec[0]; + const TA_MAType ma_type = (TA_MAType)spec[1]; + + // track the largest lookback seen so far + const int ma_lookback = TA_MA_Lookback(period, ma_type); + if (ma_lookback > lookback) { + lookback = ma_lookback; + } - const int period = specification_ptr[0]; - const TA_MAType ma_type = (TA_MAType)specification_ptr[1]; + // moving average is written into column (j + 1) + double *restrict ma = output_ptr + (size_t)(j + 1) * (size_t)n; - double *restrict offset_real = output_ptr + (size_t)(j + 1) * (size_t)n; + int start_idx = 0; + int end_idx = 0; // clang-format off - // calculate moving averages TA_RetCode return_value = TA_MA( 0, n - 1, @@ -102,27 +139,24 @@ SEXP impl_ta_VOLUME( ma_type, &start_idx, &end_idx, - offset_real + ma ); - - // validate output - check_output(return_value, protection_count); // clang-format on + check_output(return_value, protection_count); - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with + // pad the leading 'start_idx' rows with so the column has 'n' rows // see shift.h for more details - shift_array(offset_real, n, start_idx); + shift_array(ma, n, start_idx); - char *character_buffer = (char *)R_alloc(32, sizeof(char)); - snprintf(character_buffer, 32, "%s%d", _MAType_(ma_type), period); - colname[j + 1] = character_buffer; + char *buffer = (char *)R_alloc(32, sizeof(char)); + snprintf(buffer, 32, "%s%d", _MAType_(ma_type), period); + colname[j + 1] = buffer; } - // set the remaining column names - // see names.h for more details + // set the column names and the (maximum) lookback attribute + // see names.h and attributes.h for more details column_names(output, n_cols, colname); + set_attribute(output, lookback, &protection_count); // re-expand output if NAs were stripped // see na.h for more details diff --git a/src/ta_WCLPRICE.c b/src/ta_WCLPRICE.c index 00874106..c22c5117 100644 --- a/src/ta_WCLPRICE.c +++ b/src/ta_WCLPRICE.c @@ -23,6 +23,36 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_WCLPRICE_lookback( + SEXP inHigh, + SEXP inLow, + SEXP inClose +) +// clang-format on +{ + // values + // get length of 'inHigh' (assumes equal length across input) + int n = LENGTH(inHigh); + + // pointers to input arrays + const double *inHigh_ptr = REAL(inHigh); + const double *inLow_ptr = REAL(inLow); + const double *inClose_ptr = REAL(inClose); + + // calculate lookback + const int lookback = TA_WCLPRICE_Lookback(); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_WCLPRICE( SEXP inHigh, diff --git a/src/ta_WILLR.c b/src/ta_WILLR.c index 7e581d88..60040b6b 100644 --- a/src/ta_WILLR.c +++ b/src/ta_WILLR.c @@ -24,6 +24,40 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_WILLR_lookback( + SEXP inHigh, + SEXP inLow, + SEXP inClose, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inHigh' (assumes equal length across input) + int n = LENGTH(inHigh); + + // pointers to input arrays + const double *inHigh_ptr = REAL(inHigh); + const double *inLow_ptr = REAL(inLow); + const double *inClose_ptr = REAL(inClose); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_WILLR_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_WILLR( SEXP inHigh, diff --git a/src/ta_WMA.c b/src/ta_WMA.c index e6b5fe28..889a4776 100644 --- a/src/ta_WMA.c +++ b/src/ta_WMA.c @@ -22,6 +22,36 @@ #include #include +// the lookback function +// is exported as a standalone +// function for downstream wrappers +// clang-format off +SEXP impl_ta_WMA_lookback( + SEXP inReal, + SEXP optInTimePeriod +) +// clang-format on +{ + // values + // get length of 'inReal' (assumes equal length across input) + int n = LENGTH(inReal); + + // pointers to input arrays + const double *inReal_ptr = REAL(inReal); + + // extract input values + const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; + + // calculate lookback + const int lookback = TA_WMA_Lookback(optInTimePeriod_value); + + SEXP output = PROTECT(Rf_ScalarInteger(lookback)); + + // unprotect output + UNPROTECT(1); + return output; +} + // clang-format off SEXP impl_ta_WMA( SEXP inReal, diff --git a/tests/testthat/test-ta_ACCBANDS.R b/tests/testthat/test-ta_ACCBANDS.R index 2bce7be9..d27f7b6e 100644 --- a/tests/testthat/test-ta_ACCBANDS.R +++ b/tests/testthat/test-ta_ACCBANDS.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + acceleration_bands(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = acceleration_bands, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_AD.R b/tests/testthat/test-ta_AD.R index 28d61d69..aa72aabc 100644 --- a/tests/testthat/test-ta_AD.R +++ b/tests/testthat/test-ta_AD.R @@ -145,6 +145,24 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + chaikin_accumulation_distribution_line(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback( + FUN = chaikin_accumulation_distribution_line, + x = SPY + ) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_ADOSC.R b/tests/testthat/test-ta_ADOSC.R index 9ed88a8d..02e4e468 100644 --- a/tests/testthat/test-ta_ADOSC.R +++ b/tests/testthat/test-ta_ADOSC.R @@ -148,6 +148,24 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + chaikin_accumulation_distribution_oscillator(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback( + FUN = chaikin_accumulation_distribution_oscillator, + x = SPY + ) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_ADX.R b/tests/testthat/test-ta_ADX.R index aa0e9f65..ad23c49b 100644 --- a/tests/testthat/test-ta_ADX.R +++ b/tests/testthat/test-ta_ADX.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + average_directional_movement_index(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = average_directional_movement_index, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_ADXR.R b/tests/testthat/test-ta_ADXR.R index ce5f58cb..3169fe75 100644 --- a/tests/testthat/test-ta_ADXR.R +++ b/tests/testthat/test-ta_ADXR.R @@ -148,6 +148,24 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + average_directional_movement_index_rating(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback( + FUN = average_directional_movement_index_rating, + x = SPY + ) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_APO.R b/tests/testthat/test-ta_APO.R index 6a44cfee..87fe1148 100644 --- a/tests/testthat/test-ta_APO.R +++ b/tests/testthat/test-ta_APO.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + absolute_price_oscillator(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = absolute_price_oscillator, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_AROON.R b/tests/testthat/test-ta_AROON.R index adfbecc4..737e5d5a 100644 --- a/tests/testthat/test-ta_AROON.R +++ b/tests/testthat/test-ta_AROON.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + aroon(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = aroon, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_AROONOSC.R b/tests/testthat/test-ta_AROONOSC.R index 6c96b785..0fe1ce0c 100644 --- a/tests/testthat/test-ta_AROONOSC.R +++ b/tests/testthat/test-ta_AROONOSC.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + aroon_oscillator(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = aroon_oscillator, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_ATR.R b/tests/testthat/test-ta_ATR.R index 4745c6a8..abc4294a 100644 --- a/tests/testthat/test-ta_ATR.R +++ b/tests/testthat/test-ta_ATR.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + average_true_range(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = average_true_range, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_AVGPRICE.R b/tests/testthat/test-ta_AVGPRICE.R index a6ae729b..35525c9d 100644 --- a/tests/testthat/test-ta_AVGPRICE.R +++ b/tests/testthat/test-ta_AVGPRICE.R @@ -143,3 +143,18 @@ testthat::test_that(desc = 'Row names are respected for ', code = { expected = rownames(indicator) ) }) + + +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + average_price(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = average_price, x = SPY) + ) +}) diff --git a/tests/testthat/test-ta_BBANDS.R b/tests/testthat/test-ta_BBANDS.R index 238809d1..fe9113bc 100644 --- a/tests/testthat/test-ta_BBANDS.R +++ b/tests/testthat/test-ta_BBANDS.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + bollinger_bands(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = bollinger_bands, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_BETA.R b/tests/testthat/test-ta_BETA.R index 282d80d7..21cf6b53 100644 --- a/tests/testthat/test-ta_BETA.R +++ b/tests/testthat/test-ta_BETA.R @@ -43,6 +43,20 @@ testthat::test_that(desc = 'Output type', code = { ) testthat::expect_true( - is.vector(output) + is.null(dim(output)) + ) +}) + +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + rolling_beta(x = SPY[, 1], y = SPY[, 2]), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = rolling_beta, x = SPY[, 1], y = SPY[, 2]) ) }) diff --git a/tests/testthat/test-ta_BOP.R b/tests/testthat/test-ta_BOP.R index 55707da8..ab00b9c4 100644 --- a/tests/testthat/test-ta_BOP.R +++ b/tests/testthat/test-ta_BOP.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + balance_of_power(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = balance_of_power, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CCI.R b/tests/testthat/test-ta_CCI.R index 00ae8c3d..fb88cdc5 100644 --- a/tests/testthat/test-ta_CCI.R +++ b/tests/testthat/test-ta_CCI.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + commodity_channel_index(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = commodity_channel_index, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDL2CROWS.R b/tests/testthat/test-ta_CDL2CROWS.R index be0fcce2..57e89c09 100644 --- a/tests/testthat/test-ta_CDL2CROWS.R +++ b/tests/testthat/test-ta_CDL2CROWS.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + two_crows(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = two_crows, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDL3BLACKCROWS.R b/tests/testthat/test-ta_CDL3BLACKCROWS.R index 3ffbd29c..ae024da6 100644 --- a/tests/testthat/test-ta_CDL3BLACKCROWS.R +++ b/tests/testthat/test-ta_CDL3BLACKCROWS.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + three_black_crows(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = three_black_crows, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDL3INSIDE.R b/tests/testthat/test-ta_CDL3INSIDE.R index 904d06ff..b01e35a8 100644 --- a/tests/testthat/test-ta_CDL3INSIDE.R +++ b/tests/testthat/test-ta_CDL3INSIDE.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + three_inside(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = three_inside, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDL3LINESTRIKE.R b/tests/testthat/test-ta_CDL3LINESTRIKE.R index 52f5f28a..d90a2a52 100644 --- a/tests/testthat/test-ta_CDL3LINESTRIKE.R +++ b/tests/testthat/test-ta_CDL3LINESTRIKE.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + three_line_strike(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = three_line_strike, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDL3OUTSIDE.R b/tests/testthat/test-ta_CDL3OUTSIDE.R index 1e0d888a..8bd959af 100644 --- a/tests/testthat/test-ta_CDL3OUTSIDE.R +++ b/tests/testthat/test-ta_CDL3OUTSIDE.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + three_outside(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = three_outside, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDL3STARSINSOUTH.R b/tests/testthat/test-ta_CDL3STARSINSOUTH.R index 4949a6f1..7711c379 100644 --- a/tests/testthat/test-ta_CDL3STARSINSOUTH.R +++ b/tests/testthat/test-ta_CDL3STARSINSOUTH.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + three_stars_in_the_south(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = three_stars_in_the_south, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDL3WHITESOLDIERS.R b/tests/testthat/test-ta_CDL3WHITESOLDIERS.R index 2fead055..1090b3a2 100644 --- a/tests/testthat/test-ta_CDL3WHITESOLDIERS.R +++ b/tests/testthat/test-ta_CDL3WHITESOLDIERS.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + three_white_soldiers(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = three_white_soldiers, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLABANDONEDBABY.R b/tests/testthat/test-ta_CDLABANDONEDBABY.R index 8af4d3e6..a756c7c0 100644 --- a/tests/testthat/test-ta_CDLABANDONEDBABY.R +++ b/tests/testthat/test-ta_CDLABANDONEDBABY.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + abandoned_baby(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = abandoned_baby, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLADVANCEBLOCK.R b/tests/testthat/test-ta_CDLADVANCEBLOCK.R index 99841b11..0b2d49de 100644 --- a/tests/testthat/test-ta_CDLADVANCEBLOCK.R +++ b/tests/testthat/test-ta_CDLADVANCEBLOCK.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + advance_block(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = advance_block, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLBELTHOLD.R b/tests/testthat/test-ta_CDLBELTHOLD.R index cf98c69c..0925897d 100644 --- a/tests/testthat/test-ta_CDLBELTHOLD.R +++ b/tests/testthat/test-ta_CDLBELTHOLD.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + belt_hold(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = belt_hold, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLBREAKAWAY.R b/tests/testthat/test-ta_CDLBREAKAWAY.R index bc510b1b..5d7742f7 100644 --- a/tests/testthat/test-ta_CDLBREAKAWAY.R +++ b/tests/testthat/test-ta_CDLBREAKAWAY.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + break_away(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = break_away, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLCLOSINGMARUBOZU.R b/tests/testthat/test-ta_CDLCLOSINGMARUBOZU.R index d3e9fc72..fbadbae5 100644 --- a/tests/testthat/test-ta_CDLCLOSINGMARUBOZU.R +++ b/tests/testthat/test-ta_CDLCLOSINGMARUBOZU.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + closing_marubozu(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = closing_marubozu, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLCONCEALBABYSWALL.R b/tests/testthat/test-ta_CDLCONCEALBABYSWALL.R index 6e5bbf61..01944539 100644 --- a/tests/testthat/test-ta_CDLCONCEALBABYSWALL.R +++ b/tests/testthat/test-ta_CDLCONCEALBABYSWALL.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + concealing_baby_swallow(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = concealing_baby_swallow, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLCOUNTERATTACK.R b/tests/testthat/test-ta_CDLCOUNTERATTACK.R index 2de3e431..6b88529b 100644 --- a/tests/testthat/test-ta_CDLCOUNTERATTACK.R +++ b/tests/testthat/test-ta_CDLCOUNTERATTACK.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + counter_attack(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = counter_attack, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLDARKCLOUDCOVER.R b/tests/testthat/test-ta_CDLDARKCLOUDCOVER.R index df221cf6..887072ee 100644 --- a/tests/testthat/test-ta_CDLDARKCLOUDCOVER.R +++ b/tests/testthat/test-ta_CDLDARKCLOUDCOVER.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + dark_cloud_cover(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = dark_cloud_cover, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLDOJI.R b/tests/testthat/test-ta_CDLDOJI.R index 67e041f0..9be0ca7a 100644 --- a/tests/testthat/test-ta_CDLDOJI.R +++ b/tests/testthat/test-ta_CDLDOJI.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + doji(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = doji, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLDOJISTAR.R b/tests/testthat/test-ta_CDLDOJISTAR.R index cc48aedd..3dd27de8 100644 --- a/tests/testthat/test-ta_CDLDOJISTAR.R +++ b/tests/testthat/test-ta_CDLDOJISTAR.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + doji_star(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = doji_star, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLDRAGONFLYDOJI.R b/tests/testthat/test-ta_CDLDRAGONFLYDOJI.R index 098c4816..7b5f5fbb 100644 --- a/tests/testthat/test-ta_CDLDRAGONFLYDOJI.R +++ b/tests/testthat/test-ta_CDLDRAGONFLYDOJI.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + dragonfly_doji(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = dragonfly_doji, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLENGULFING.R b/tests/testthat/test-ta_CDLENGULFING.R index fa7e4c09..b6de41d3 100644 --- a/tests/testthat/test-ta_CDLENGULFING.R +++ b/tests/testthat/test-ta_CDLENGULFING.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + engulfing(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = engulfing, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLEVENINGDOJISTAR.R b/tests/testthat/test-ta_CDLEVENINGDOJISTAR.R index b4b9b5fc..e88be9f8 100644 --- a/tests/testthat/test-ta_CDLEVENINGDOJISTAR.R +++ b/tests/testthat/test-ta_CDLEVENINGDOJISTAR.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + evening_doji_star(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = evening_doji_star, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLEVENINGSTAR.R b/tests/testthat/test-ta_CDLEVENINGSTAR.R index a8a232d0..2fd5dd7e 100644 --- a/tests/testthat/test-ta_CDLEVENINGSTAR.R +++ b/tests/testthat/test-ta_CDLEVENINGSTAR.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + evening_star(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = evening_star, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLGAPSIDESIDEWHITE.R b/tests/testthat/test-ta_CDLGAPSIDESIDEWHITE.R index 10e7f8a0..2cede5c7 100644 --- a/tests/testthat/test-ta_CDLGAPSIDESIDEWHITE.R +++ b/tests/testthat/test-ta_CDLGAPSIDESIDEWHITE.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + gaps_side_white(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = gaps_side_white, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLGRAVESTONEDOJI.R b/tests/testthat/test-ta_CDLGRAVESTONEDOJI.R index 16093653..e9b9547e 100644 --- a/tests/testthat/test-ta_CDLGRAVESTONEDOJI.R +++ b/tests/testthat/test-ta_CDLGRAVESTONEDOJI.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + gravestone_doji(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = gravestone_doji, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLHAMMER.R b/tests/testthat/test-ta_CDLHAMMER.R index 047e42d2..89769d5f 100644 --- a/tests/testthat/test-ta_CDLHAMMER.R +++ b/tests/testthat/test-ta_CDLHAMMER.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + hammer(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = hammer, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLHANGINGMAN.R b/tests/testthat/test-ta_CDLHANGINGMAN.R index da708471..293d1858 100644 --- a/tests/testthat/test-ta_CDLHANGINGMAN.R +++ b/tests/testthat/test-ta_CDLHANGINGMAN.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + hanging_man(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = hanging_man, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLHARAMI.R b/tests/testthat/test-ta_CDLHARAMI.R index 7ee501a5..ad4d92e7 100644 --- a/tests/testthat/test-ta_CDLHARAMI.R +++ b/tests/testthat/test-ta_CDLHARAMI.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + harami(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = harami, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLHARAMICROSS.R b/tests/testthat/test-ta_CDLHARAMICROSS.R index 7a61982b..36662125 100644 --- a/tests/testthat/test-ta_CDLHARAMICROSS.R +++ b/tests/testthat/test-ta_CDLHARAMICROSS.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + harami_cross(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = harami_cross, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLHIGHWAVE.R b/tests/testthat/test-ta_CDLHIGHWAVE.R index d928d8fc..d8fd29fc 100644 --- a/tests/testthat/test-ta_CDLHIGHWAVE.R +++ b/tests/testthat/test-ta_CDLHIGHWAVE.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + high_wave(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = high_wave, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLHIKKAKE.R b/tests/testthat/test-ta_CDLHIKKAKE.R index a1639124..8ff70193 100644 --- a/tests/testthat/test-ta_CDLHIKKAKE.R +++ b/tests/testthat/test-ta_CDLHIKKAKE.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + hikakke(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = hikakke, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLHIKKAKEMOD.R b/tests/testthat/test-ta_CDLHIKKAKEMOD.R index 82eecd15..f08218c2 100644 --- a/tests/testthat/test-ta_CDLHIKKAKEMOD.R +++ b/tests/testthat/test-ta_CDLHIKKAKEMOD.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + hikakke_mod(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = hikakke_mod, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLHOMINGPIGEON.R b/tests/testthat/test-ta_CDLHOMINGPIGEON.R index c2ea37ec..dcbdcdbd 100644 --- a/tests/testthat/test-ta_CDLHOMINGPIGEON.R +++ b/tests/testthat/test-ta_CDLHOMINGPIGEON.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + homing_pigeon(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = homing_pigeon, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLIDENTICAL3CROWS.R b/tests/testthat/test-ta_CDLIDENTICAL3CROWS.R index c001ea8f..efc977d0 100644 --- a/tests/testthat/test-ta_CDLIDENTICAL3CROWS.R +++ b/tests/testthat/test-ta_CDLIDENTICAL3CROWS.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + three_identical_crows(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = three_identical_crows, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLINNECK.R b/tests/testthat/test-ta_CDLINNECK.R index 17b847b8..67a0ffc9 100644 --- a/tests/testthat/test-ta_CDLINNECK.R +++ b/tests/testthat/test-ta_CDLINNECK.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + in_neck(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = in_neck, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLINVERTEDHAMMER.R b/tests/testthat/test-ta_CDLINVERTEDHAMMER.R index 5a72d69e..081a9961 100644 --- a/tests/testthat/test-ta_CDLINVERTEDHAMMER.R +++ b/tests/testthat/test-ta_CDLINVERTEDHAMMER.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + inverted_hammer(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = inverted_hammer, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLKICKING.R b/tests/testthat/test-ta_CDLKICKING.R index 54e26ba4..0e544cec 100644 --- a/tests/testthat/test-ta_CDLKICKING.R +++ b/tests/testthat/test-ta_CDLKICKING.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + kicking(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = kicking, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLKICKINGBYLENGTH.R b/tests/testthat/test-ta_CDLKICKINGBYLENGTH.R index 96b3dd15..81efb459 100644 --- a/tests/testthat/test-ta_CDLKICKINGBYLENGTH.R +++ b/tests/testthat/test-ta_CDLKICKINGBYLENGTH.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + kicking_baby_length(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = kicking_baby_length, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLLADDERBOTTOM.R b/tests/testthat/test-ta_CDLLADDERBOTTOM.R index 75d5b4bc..74170a8a 100644 --- a/tests/testthat/test-ta_CDLLADDERBOTTOM.R +++ b/tests/testthat/test-ta_CDLLADDERBOTTOM.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + ladder_bottom(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = ladder_bottom, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLLONGLEGGEDDOJI.R b/tests/testthat/test-ta_CDLLONGLEGGEDDOJI.R index 353ca3b2..0ca3a2d6 100644 --- a/tests/testthat/test-ta_CDLLONGLEGGEDDOJI.R +++ b/tests/testthat/test-ta_CDLLONGLEGGEDDOJI.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + long_legged_doji(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = long_legged_doji, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLLONGLINE.R b/tests/testthat/test-ta_CDLLONGLINE.R index 8982d3e8..550647bf 100644 --- a/tests/testthat/test-ta_CDLLONGLINE.R +++ b/tests/testthat/test-ta_CDLLONGLINE.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + long_line(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = long_line, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLMARUBOZU.R b/tests/testthat/test-ta_CDLMARUBOZU.R index 2aa85275..8cfa0244 100644 --- a/tests/testthat/test-ta_CDLMARUBOZU.R +++ b/tests/testthat/test-ta_CDLMARUBOZU.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + marubozu(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = marubozu, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLMATCHINGLOW.R b/tests/testthat/test-ta_CDLMATCHINGLOW.R index cc0b2d13..e340936e 100644 --- a/tests/testthat/test-ta_CDLMATCHINGLOW.R +++ b/tests/testthat/test-ta_CDLMATCHINGLOW.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + matching_low(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = matching_low, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLMATHOLD.R b/tests/testthat/test-ta_CDLMATHOLD.R index 3061c6f9..19d711cb 100644 --- a/tests/testthat/test-ta_CDLMATHOLD.R +++ b/tests/testthat/test-ta_CDLMATHOLD.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + mat_hold(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = mat_hold, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLMORNINGDOJISTAR.R b/tests/testthat/test-ta_CDLMORNINGDOJISTAR.R index 4e9d131e..ec281f22 100644 --- a/tests/testthat/test-ta_CDLMORNINGDOJISTAR.R +++ b/tests/testthat/test-ta_CDLMORNINGDOJISTAR.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + morning_doji_star(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = morning_doji_star, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLMORNINGSTAR.R b/tests/testthat/test-ta_CDLMORNINGSTAR.R index fb04a8d4..1701248c 100644 --- a/tests/testthat/test-ta_CDLMORNINGSTAR.R +++ b/tests/testthat/test-ta_CDLMORNINGSTAR.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + morning_star(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = morning_star, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLONNECK.R b/tests/testthat/test-ta_CDLONNECK.R index a18cf4f9..e62388a5 100644 --- a/tests/testthat/test-ta_CDLONNECK.R +++ b/tests/testthat/test-ta_CDLONNECK.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + on_neck(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = on_neck, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLPIERCING.R b/tests/testthat/test-ta_CDLPIERCING.R index 118b1041..4734b0de 100644 --- a/tests/testthat/test-ta_CDLPIERCING.R +++ b/tests/testthat/test-ta_CDLPIERCING.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + piercing(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = piercing, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLRICKSHAWMAN.R b/tests/testthat/test-ta_CDLRICKSHAWMAN.R index 9b5de990..3e7b17e1 100644 --- a/tests/testthat/test-ta_CDLRICKSHAWMAN.R +++ b/tests/testthat/test-ta_CDLRICKSHAWMAN.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + rickshaw_man(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = rickshaw_man, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLRISEFALL3METHODS.R b/tests/testthat/test-ta_CDLRISEFALL3METHODS.R index 4a9f7fe7..1510aaf7 100644 --- a/tests/testthat/test-ta_CDLRISEFALL3METHODS.R +++ b/tests/testthat/test-ta_CDLRISEFALL3METHODS.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + rise_fall_3_methods(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = rise_fall_3_methods, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLSEPARATINGLINES.R b/tests/testthat/test-ta_CDLSEPARATINGLINES.R index 7756e474..e7006563 100644 --- a/tests/testthat/test-ta_CDLSEPARATINGLINES.R +++ b/tests/testthat/test-ta_CDLSEPARATINGLINES.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + separating_lines(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = separating_lines, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLSHOOTINGSTAR.R b/tests/testthat/test-ta_CDLSHOOTINGSTAR.R index 7af511f6..3a7010c9 100644 --- a/tests/testthat/test-ta_CDLSHOOTINGSTAR.R +++ b/tests/testthat/test-ta_CDLSHOOTINGSTAR.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + shooting_star(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = shooting_star, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLSHORTLINE.R b/tests/testthat/test-ta_CDLSHORTLINE.R index b98f773b..c71da3c5 100644 --- a/tests/testthat/test-ta_CDLSHORTLINE.R +++ b/tests/testthat/test-ta_CDLSHORTLINE.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + short_line(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = short_line, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLSPINNINGTOP.R b/tests/testthat/test-ta_CDLSPINNINGTOP.R index 6bd2ec37..848de088 100644 --- a/tests/testthat/test-ta_CDLSPINNINGTOP.R +++ b/tests/testthat/test-ta_CDLSPINNINGTOP.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + spinning_top(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = spinning_top, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLSTALLEDPATTERN.R b/tests/testthat/test-ta_CDLSTALLEDPATTERN.R index 7e2bdff9..7a08ac4c 100644 --- a/tests/testthat/test-ta_CDLSTALLEDPATTERN.R +++ b/tests/testthat/test-ta_CDLSTALLEDPATTERN.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + stalled_pattern(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = stalled_pattern, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLSTICKSANDWICH.R b/tests/testthat/test-ta_CDLSTICKSANDWICH.R index a083b659..66efd60a 100644 --- a/tests/testthat/test-ta_CDLSTICKSANDWICH.R +++ b/tests/testthat/test-ta_CDLSTICKSANDWICH.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + stick_sandwich(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = stick_sandwich, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLTAKURI.R b/tests/testthat/test-ta_CDLTAKURI.R index ca4ddf6c..aa9d1a6d 100644 --- a/tests/testthat/test-ta_CDLTAKURI.R +++ b/tests/testthat/test-ta_CDLTAKURI.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + takuri(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = takuri, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLTASUKIGAP.R b/tests/testthat/test-ta_CDLTASUKIGAP.R index 15133857..e652c912 100644 --- a/tests/testthat/test-ta_CDLTASUKIGAP.R +++ b/tests/testthat/test-ta_CDLTASUKIGAP.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + tasuki_gap(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = tasuki_gap, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLTHRUSTING.R b/tests/testthat/test-ta_CDLTHRUSTING.R index 775b2c9f..895e3345 100644 --- a/tests/testthat/test-ta_CDLTHRUSTING.R +++ b/tests/testthat/test-ta_CDLTHRUSTING.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + thrusting(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = thrusting, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLTRISTAR.R b/tests/testthat/test-ta_CDLTRISTAR.R index 561cd18d..2bd3d5a7 100644 --- a/tests/testthat/test-ta_CDLTRISTAR.R +++ b/tests/testthat/test-ta_CDLTRISTAR.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + tristar(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = tristar, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLUNIQUE3RIVER.R b/tests/testthat/test-ta_CDLUNIQUE3RIVER.R index 59f06585..48f97a82 100644 --- a/tests/testthat/test-ta_CDLUNIQUE3RIVER.R +++ b/tests/testthat/test-ta_CDLUNIQUE3RIVER.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + unique_3_river(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = unique_3_river, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLUPSIDEGAP2CROWS.R b/tests/testthat/test-ta_CDLUPSIDEGAP2CROWS.R index cb8d12ad..98279084 100644 --- a/tests/testthat/test-ta_CDLUPSIDEGAP2CROWS.R +++ b/tests/testthat/test-ta_CDLUPSIDEGAP2CROWS.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + upside_gap_2_crows(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = upside_gap_2_crows, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLXSIDEGAP3METHODS.R b/tests/testthat/test-ta_CDLXSIDEGAP3METHODS.R index f4b20b9e..710f3b90 100644 --- a/tests/testthat/test-ta_CDLXSIDEGAP3METHODS.R +++ b/tests/testthat/test-ta_CDLXSIDEGAP3METHODS.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + xside_gap_3_methods(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = xside_gap_3_methods, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CMO.R b/tests/testthat/test-ta_CMO.R index f4ebea87..dcb4b189 100644 --- a/tests/testthat/test-ta_CMO.R +++ b/tests/testthat/test-ta_CMO.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + chande_momentum_oscillator(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = chande_momentum_oscillator, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CORREL.R b/tests/testthat/test-ta_CORREL.R index c68b4c94..b4e8d61b 100644 --- a/tests/testthat/test-ta_CORREL.R +++ b/tests/testthat/test-ta_CORREL.R @@ -43,6 +43,24 @@ testthat::test_that(desc = 'Output type', code = { ) testthat::expect_true( - is.vector(output) + is.null(dim(output)) + ) +}) + +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + rolling_correlation(x = SPY[, 1], y = SPY[, 2]), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback( + FUN = rolling_correlation, + x = SPY[, 1], + y = SPY[, 2] + ) ) }) diff --git a/tests/testthat/test-ta_DEMA.R b/tests/testthat/test-ta_DEMA.R index 6a6ba8e7..6ac122e4 100644 --- a/tests/testthat/test-ta_DEMA.R +++ b/tests/testthat/test-ta_DEMA.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + double_exponential_moving_average(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = double_exponential_moving_average, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_DX.R b/tests/testthat/test-ta_DX.R index 0ef9a0ec..06e96132 100644 --- a/tests/testthat/test-ta_DX.R +++ b/tests/testthat/test-ta_DX.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + directional_movement_index(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = directional_movement_index, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_EMA.R b/tests/testthat/test-ta_EMA.R index 9727c2f6..7ce7411a 100644 --- a/tests/testthat/test-ta_EMA.R +++ b/tests/testthat/test-ta_EMA.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + exponential_moving_average(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = exponential_moving_average, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_HT_DCPERIOD.R b/tests/testthat/test-ta_HT_DCPERIOD.R index 8ccdab5e..79bfb9c8 100644 --- a/tests/testthat/test-ta_HT_DCPERIOD.R +++ b/tests/testthat/test-ta_HT_DCPERIOD.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + dominant_cycle_period(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = dominant_cycle_period, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_HT_DCPHASE.R b/tests/testthat/test-ta_HT_DCPHASE.R index d2db1826..8a7338f0 100644 --- a/tests/testthat/test-ta_HT_DCPHASE.R +++ b/tests/testthat/test-ta_HT_DCPHASE.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + dominant_cycle_phase(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = dominant_cycle_phase, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_HT_PHASOR.R b/tests/testthat/test-ta_HT_PHASOR.R index f08458d9..0f4a33f0 100644 --- a/tests/testthat/test-ta_HT_PHASOR.R +++ b/tests/testthat/test-ta_HT_PHASOR.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + phasor_components(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = phasor_components, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_HT_SINE.R b/tests/testthat/test-ta_HT_SINE.R index 501aaf0c..b3e390cc 100644 --- a/tests/testthat/test-ta_HT_SINE.R +++ b/tests/testthat/test-ta_HT_SINE.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + sine_wave(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = sine_wave, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_HT_TRENDLINE.R b/tests/testthat/test-ta_HT_TRENDLINE.R index 2989d5a3..50ab6c80 100644 --- a/tests/testthat/test-ta_HT_TRENDLINE.R +++ b/tests/testthat/test-ta_HT_TRENDLINE.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + trendline(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = trendline, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_HT_TRENDMODE.R b/tests/testthat/test-ta_HT_TRENDMODE.R index d3cdaa2a..28cd15d7 100644 --- a/tests/testthat/test-ta_HT_TRENDMODE.R +++ b/tests/testthat/test-ta_HT_TRENDMODE.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + trend_cycle_mode(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = trend_cycle_mode, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_IMI.R b/tests/testthat/test-ta_IMI.R index 586fd435..68dc4224 100644 --- a/tests/testthat/test-ta_IMI.R +++ b/tests/testthat/test-ta_IMI.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + intraday_movement_index(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = intraday_movement_index, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_KAMA.R b/tests/testthat/test-ta_KAMA.R index 3aa0f28b..f91c42f8 100644 --- a/tests/testthat/test-ta_KAMA.R +++ b/tests/testthat/test-ta_KAMA.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + kaufman_adaptive_moving_average(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = kaufman_adaptive_moving_average, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_MACD.R b/tests/testthat/test-ta_MACD.R index 36a1ae58..004baf06 100644 --- a/tests/testthat/test-ta_MACD.R +++ b/tests/testthat/test-ta_MACD.R @@ -145,6 +145,24 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + moving_average_convergence_divergence(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback( + FUN = moving_average_convergence_divergence, + x = SPY + ) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_MACDEXT.R b/tests/testthat/test-ta_MACDEXT.R index 72fb5980..b46ef0ed 100644 --- a/tests/testthat/test-ta_MACDEXT.R +++ b/tests/testthat/test-ta_MACDEXT.R @@ -154,6 +154,24 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + extended_moving_average_convergence_divergence(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback( + FUN = extended_moving_average_convergence_divergence, + x = SPY + ) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_MACDFIX.R b/tests/testthat/test-ta_MACDFIX.R index dc316ca4..e647d7ee 100644 --- a/tests/testthat/test-ta_MACDFIX.R +++ b/tests/testthat/test-ta_MACDFIX.R @@ -148,6 +148,24 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + fixed_moving_average_convergence_divergence(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback( + FUN = fixed_moving_average_convergence_divergence, + x = SPY + ) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_MAMA.R b/tests/testthat/test-ta_MAMA.R index 43eefc0e..bd9c438d 100644 --- a/tests/testthat/test-ta_MAMA.R +++ b/tests/testthat/test-ta_MAMA.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + mesa_adaptive_moving_average(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = mesa_adaptive_moving_average, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_MAX.R b/tests/testthat/test-ta_MAX.R index 73163c43..73fccaf5 100644 --- a/tests/testthat/test-ta_MAX.R +++ b/tests/testthat/test-ta_MAX.R @@ -40,6 +40,20 @@ testthat::test_that(desc = 'Output type', code = { ) testthat::expect_true( - is.vector(output) + is.null(dim(output)) + ) +}) + +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + rolling_max(x = SPY[, 1]), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = rolling_max, x = SPY[, 1]) ) }) diff --git a/tests/testthat/test-ta_MEDPRICE.R b/tests/testthat/test-ta_MEDPRICE.R index a3268f1e..5d5c0288 100644 --- a/tests/testthat/test-ta_MEDPRICE.R +++ b/tests/testthat/test-ta_MEDPRICE.R @@ -143,3 +143,18 @@ testthat::test_that(desc = 'Row names are respected for ', code = { expected = rownames(indicator) ) }) + + +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + median_price(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = median_price, x = SPY) + ) +}) diff --git a/tests/testthat/test-ta_MFI.R b/tests/testthat/test-ta_MFI.R index b6f832c3..c785d319 100644 --- a/tests/testthat/test-ta_MFI.R +++ b/tests/testthat/test-ta_MFI.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + money_flow_index(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = money_flow_index, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_MIDPRICE.R b/tests/testthat/test-ta_MIDPRICE.R index 3b0ff3d3..9ad70920 100644 --- a/tests/testthat/test-ta_MIDPRICE.R +++ b/tests/testthat/test-ta_MIDPRICE.R @@ -143,3 +143,18 @@ testthat::test_that(desc = 'Row names are respected for ', code = { expected = rownames(indicator) ) }) + + +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + midpoint_price(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = midpoint_price, x = SPY) + ) +}) diff --git a/tests/testthat/test-ta_MIN.R b/tests/testthat/test-ta_MIN.R index 2a412137..c44c6be4 100644 --- a/tests/testthat/test-ta_MIN.R +++ b/tests/testthat/test-ta_MIN.R @@ -40,6 +40,20 @@ testthat::test_that(desc = 'Output type', code = { ) testthat::expect_true( - is.vector(output) + is.null(dim(output)) + ) +}) + +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + rolling_min(x = SPY[, 1]), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = rolling_min, x = SPY[, 1]) ) }) diff --git a/tests/testthat/test-ta_MINUS_DI.R b/tests/testthat/test-ta_MINUS_DI.R index a2d444dd..661051c7 100644 --- a/tests/testthat/test-ta_MINUS_DI.R +++ b/tests/testthat/test-ta_MINUS_DI.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + minus_directional_indicator(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = minus_directional_indicator, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_MINUS_DM.R b/tests/testthat/test-ta_MINUS_DM.R index bd13137d..56747290 100644 --- a/tests/testthat/test-ta_MINUS_DM.R +++ b/tests/testthat/test-ta_MINUS_DM.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + minus_directional_movement(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = minus_directional_movement, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_MOM.R b/tests/testthat/test-ta_MOM.R index ce5dc95e..351061be 100644 --- a/tests/testthat/test-ta_MOM.R +++ b/tests/testthat/test-ta_MOM.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + momentum(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = momentum, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_NATR.R b/tests/testthat/test-ta_NATR.R index 5d3e8d6c..2e73d0da 100644 --- a/tests/testthat/test-ta_NATR.R +++ b/tests/testthat/test-ta_NATR.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + normalized_average_true_range(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = normalized_average_true_range, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_OBV.R b/tests/testthat/test-ta_OBV.R index e15438b2..3cf6baa4 100644 --- a/tests/testthat/test-ta_OBV.R +++ b/tests/testthat/test-ta_OBV.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + on_balance_volume(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = on_balance_volume, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_PLUS_DI.R b/tests/testthat/test-ta_PLUS_DI.R index 252e91b8..56bb268d 100644 --- a/tests/testthat/test-ta_PLUS_DI.R +++ b/tests/testthat/test-ta_PLUS_DI.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + plus_directional_indicator(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = plus_directional_indicator, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_PLUS_DM.R b/tests/testthat/test-ta_PLUS_DM.R index 2e960ee9..d3382d5a 100644 --- a/tests/testthat/test-ta_PLUS_DM.R +++ b/tests/testthat/test-ta_PLUS_DM.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + plus_directional_movement(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = plus_directional_movement, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_PPO.R b/tests/testthat/test-ta_PPO.R index 963cb3bb..7604a854 100644 --- a/tests/testthat/test-ta_PPO.R +++ b/tests/testthat/test-ta_PPO.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + percentage_price_oscillator(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = percentage_price_oscillator, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_ROC.R b/tests/testthat/test-ta_ROC.R index 9ac9dff8..be355b32 100644 --- a/tests/testthat/test-ta_ROC.R +++ b/tests/testthat/test-ta_ROC.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + rate_of_change(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = rate_of_change, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_ROCR.R b/tests/testthat/test-ta_ROCR.R index 3224cb18..25686279 100644 --- a/tests/testthat/test-ta_ROCR.R +++ b/tests/testthat/test-ta_ROCR.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + ratio_of_change(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = ratio_of_change, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_RSI.R b/tests/testthat/test-ta_RSI.R index 40cc132d..9da8de1a 100644 --- a/tests/testthat/test-ta_RSI.R +++ b/tests/testthat/test-ta_RSI.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + relative_strength_index(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = relative_strength_index, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_SAR.R b/tests/testthat/test-ta_SAR.R index a3e0a58d..b3d8365b 100644 --- a/tests/testthat/test-ta_SAR.R +++ b/tests/testthat/test-ta_SAR.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + parabolic_stop_and_reverse(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = parabolic_stop_and_reverse, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_SAREXT.R b/tests/testthat/test-ta_SAREXT.R index 3489c4c7..136e064f 100644 --- a/tests/testthat/test-ta_SAREXT.R +++ b/tests/testthat/test-ta_SAREXT.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + extended_parabolic_stop_and_reverse(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = extended_parabolic_stop_and_reverse, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_SMA.R b/tests/testthat/test-ta_SMA.R index 3e09822d..ac374c92 100644 --- a/tests/testthat/test-ta_SMA.R +++ b/tests/testthat/test-ta_SMA.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + simple_moving_average(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = simple_moving_average, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_STDDEV.R b/tests/testthat/test-ta_STDDEV.R index cc0487c5..41b2dcab 100644 --- a/tests/testthat/test-ta_STDDEV.R +++ b/tests/testthat/test-ta_STDDEV.R @@ -40,6 +40,20 @@ testthat::test_that(desc = 'Output type', code = { ) testthat::expect_true( - is.vector(output) + is.null(dim(output)) + ) +}) + +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + rolling_standard_deviation(x = SPY[, 1]), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = rolling_standard_deviation, x = SPY[, 1]) ) }) diff --git a/tests/testthat/test-ta_STOCH.R b/tests/testthat/test-ta_STOCH.R index 45fcbc33..ddb54a3d 100644 --- a/tests/testthat/test-ta_STOCH.R +++ b/tests/testthat/test-ta_STOCH.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + stochastic(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = stochastic, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_STOCHF.R b/tests/testthat/test-ta_STOCHF.R index 6605c6ab..e0bf6cf3 100644 --- a/tests/testthat/test-ta_STOCHF.R +++ b/tests/testthat/test-ta_STOCHF.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + fast_stochastic(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = fast_stochastic, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_STOCHRSI.R b/tests/testthat/test-ta_STOCHRSI.R index 07f61656..ff690b20 100644 --- a/tests/testthat/test-ta_STOCHRSI.R +++ b/tests/testthat/test-ta_STOCHRSI.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + stochastic_relative_strength_index(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = stochastic_relative_strength_index, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_SUM.R b/tests/testthat/test-ta_SUM.R index 70a64fbb..4699c4ff 100644 --- a/tests/testthat/test-ta_SUM.R +++ b/tests/testthat/test-ta_SUM.R @@ -40,6 +40,20 @@ testthat::test_that(desc = 'Output type', code = { ) testthat::expect_true( - is.vector(output) + is.null(dim(output)) + ) +}) + +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + rolling_sum(x = SPY[, 1]), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = rolling_sum, x = SPY[, 1]) ) }) diff --git a/tests/testthat/test-ta_T3.R b/tests/testthat/test-ta_T3.R index 49a2ea84..c81eeecc 100644 --- a/tests/testthat/test-ta_T3.R +++ b/tests/testthat/test-ta_T3.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + t3_exponential_moving_average(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = t3_exponential_moving_average, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_TEMA.R b/tests/testthat/test-ta_TEMA.R index 2ac581df..4e490eb9 100644 --- a/tests/testthat/test-ta_TEMA.R +++ b/tests/testthat/test-ta_TEMA.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + triple_exponential_moving_average(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = triple_exponential_moving_average, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_TRANGE.R b/tests/testthat/test-ta_TRANGE.R index de90b916..ce74863a 100644 --- a/tests/testthat/test-ta_TRANGE.R +++ b/tests/testthat/test-ta_TRANGE.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + true_range(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = true_range, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_TRIMA.R b/tests/testthat/test-ta_TRIMA.R index e2eec73a..5c1325b8 100644 --- a/tests/testthat/test-ta_TRIMA.R +++ b/tests/testthat/test-ta_TRIMA.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + triangular_moving_average(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = triangular_moving_average, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_TRIX.R b/tests/testthat/test-ta_TRIX.R index 626d5358..54383e07 100644 --- a/tests/testthat/test-ta_TRIX.R +++ b/tests/testthat/test-ta_TRIX.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + triple_exponential_average(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = triple_exponential_average, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_TYPPRICE.R b/tests/testthat/test-ta_TYPPRICE.R index d6938c5a..ff52938e 100644 --- a/tests/testthat/test-ta_TYPPRICE.R +++ b/tests/testthat/test-ta_TYPPRICE.R @@ -143,3 +143,18 @@ testthat::test_that(desc = 'Row names are respected for ', code = { expected = rownames(indicator) ) }) + + +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + typical_price(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = typical_price, x = SPY) + ) +}) diff --git a/tests/testthat/test-ta_ULTOSC.R b/tests/testthat/test-ta_ULTOSC.R index 3ddd6650..686ced54 100644 --- a/tests/testthat/test-ta_ULTOSC.R +++ b/tests/testthat/test-ta_ULTOSC.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + ultimate_oscillator(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = ultimate_oscillator, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_VAR.R b/tests/testthat/test-ta_VAR.R index 1fe3a18c..be801466 100644 --- a/tests/testthat/test-ta_VAR.R +++ b/tests/testthat/test-ta_VAR.R @@ -40,6 +40,20 @@ testthat::test_that(desc = 'Output type', code = { ) testthat::expect_true( - is.vector(output) + is.null(dim(output)) + ) +}) + +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + rolling_variance(x = SPY[, 1]), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = rolling_variance, x = SPY[, 1]) ) }) diff --git a/tests/testthat/test-ta_VOLUME.R b/tests/testthat/test-ta_VOLUME.R index 2d5ad295..9cbcd402 100644 --- a/tests/testthat/test-ta_VOLUME.R +++ b/tests/testthat/test-ta_VOLUME.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + trading_volume(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = trading_volume, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_WCLPRICE.R b/tests/testthat/test-ta_WCLPRICE.R index ab6ad34e..80cf3aed 100644 --- a/tests/testthat/test-ta_WCLPRICE.R +++ b/tests/testthat/test-ta_WCLPRICE.R @@ -143,3 +143,18 @@ testthat::test_that(desc = 'Row names are respected for ', code = { expected = rownames(indicator) ) }) + + +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + weighted_close_price(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = weighted_close_price, x = SPY) + ) +}) diff --git a/tests/testthat/test-ta_WILLR.R b/tests/testthat/test-ta_WILLR.R index a7e15e63..1c87c880 100644 --- a/tests/testthat/test-ta_WILLR.R +++ b/tests/testthat/test-ta_WILLR.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + williams_oscillator(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = williams_oscillator, x = SPY) + ) +}) + + ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_WMA.R b/tests/testthat/test-ta_WMA.R index 22d69882..c28c67de 100644 --- a/tests/testthat/test-ta_WMA.R +++ b/tests/testthat/test-ta_WMA.R @@ -145,6 +145,21 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) +## test the output's attribute "lookback" matches +## the lookback() +testthat::test_that(desc = 'Lookback equivalence', code = { + output <- attr( + weighted_moving_average(SPY), + "lookback" + ) + + testthat::expect_equal( + object = output, + expected = lookback(FUN = weighted_moving_average, x = SPY) + ) +}) + + ## -method checks for ## and ##