diff --git a/R/MovingAverages.R b/R/MovingAverages.R index 9e0c909..9e5276f 100755 --- a/R/MovingAverages.R +++ b/R/MovingAverages.R @@ -51,6 +51,11 @@ function (x, n=10, wilder=FALSE, ratio=NULL) { # Check for non-leading NAs # Leading NAs are handled in the C code x.na <- xts:::naCheck(x, n) + + # If ratio is specified, and n is not, set n to approx 'correct' + # value backed out from ratio + if(missing(n) && !missing(ratio)) + n <- trunc(2/ratio - 1) # Determine decay ratio if(is.null(ratio)) {