Skip to content

Commit

Permalink
added check for missing n when ratio is specified to EMA. If missing,…
Browse files Browse the repository at this point in the history
… converts n to approx. "correct" value given ratio

git-svn-id: svn+ssh://svn.r-forge.r-project.org/svnroot/ttr/pkg@98 edb9625f-4e0d-4859-8d74-9fd3b1da38cb
  • Loading branch information
jaryan committed Mar 11, 2010
1 parent 2a9e215 commit 0d7e9e5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions R/MovingAverages.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 0d7e9e5

Please sign in to comment.