Skip to contents

rolling_max() is a generic S3 function that preserves the input class: double vector in, double vector out.

Handling of -values

Leading NAs are always produced for the initial lookback period where insufficient data is available. If the input itself contains NAs they are passed through to the underlying C routine, which can cause the entire output to be filled with NAs. Set na.ignore = TRUE to strip NAs before calculation and re-insert them at their original positions in the output.

Usage

rolling_max(x, n = 10, na.ignore = FALSE)

Arguments

x

(double). A double vector.

n

(integer). Lookback period (window size). A positive integer of length 1.

na.ignore

(logical). A logical of length 1. FALSE by default. If TRUE, NAs in the input are stripped before calculation and re-inserted at their original positions in the output.

Value

A double vector with the same length of x

Author

Serkan Korkmaz

Examples

## load Bitcoin (BTC)
## series
data(BTC, package = "talib")

## calculate the indicator
## Open
output <- talib::rolling_max(x = BTC[[1]])

## display the results
utils::tail(output)
#> [1] 106136.9 106136.9 100146.7  99356.0  99356.0  99356.0