[Quantmod-commits] r602 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jan 18 06:29:19 CET 2013


Author: jryan
Date: 2013-01-18 06:29:19 +0100 (Fri, 18 Jan 2013)
New Revision: 602

Modified:
   pkg/R/chart_Series.R
   pkg/R/replot.R
Log:
o  add_RSI now uses a new arg wilder=TRUE, to properly manage
   the missingness criteria of TTR::RSI
o  replot changes to fix Rserve issues with.  Turns out no harm done, but issue
   has nothing to do with replot ;-)


Modified: pkg/R/chart_Series.R
===================================================================
--- pkg/R/chart_Series.R	2013-01-16 17:36:29 UTC (rev 601)
+++ pkg/R/chart_Series.R	2013-01-18 05:29:19 UTC (rev 602)
@@ -811,12 +811,13 @@
 } # }}}
 
 # add_RSI {{{
-add_RSI <- function (n=14, maType="EMA", ..., RSIup=70, RSIdn=30) {
+add_RSI <- function (n=14, maType="EMA", wilder=TRUE, ..., RSIup=70, RSIdn=30) {
+  # added in wilder=TRUE to handle missingness behavior in original TTR::RSI call
   lenv <- new.env()
-  lenv$plot_rsi <- function(x, n, maType, ...) {
+  lenv$plot_rsi <- function(x, n, maType, wilder, ...) {
     xdata <- x$Env$xdata
     xsubset <- x$Env$xsubset
-    rsi <- RSI(Cl(xdata),n=n,maType=maType)[xsubset]
+    rsi <- RSI(Cl(xdata),n=n,maType=maType,wilder=wilder)[xsubset]
     x.pos <- 1:NROW(rsi)
     theme <- x$Env$theme$rsi
     # vertical grid lines
@@ -830,11 +831,11 @@
     lines(x.pos, rsi[,1], col=x$Env$theme$rsi$col$rsi, lwd=1.5,...) 
   }
   mapply(function(name,value) { assign(name,value,envir=lenv) }, 
-        names(list(n=n,maType=maType,...)),
-              list(n=n,maType=maType,...))
+        names(list(n=n,maType=maType,wilder=wilder,...)),
+              list(n=n,maType=maType,wilder=wilder,...))
   exp <- parse(text=gsub("list","plot_rsi",
                as.expression(substitute(list(x=current.chob(),
-                                             n=n,maType=maType,...)))),
+                                             n=n,maType=maType,wilder=wilder,...)))),
                srcfile=NULL)
 
   plot_object <- current.chob()
@@ -843,7 +844,7 @@
     plot_object$Env$theme$rsi$col$lines <- "orange2"
   }
   xsubset <- plot_object$Env$xsubset
-  rsi <- RSI(Cl(plot_object$Env$xdata),n=n,maType=maType)
+  rsi <- RSI(Cl(plot_object$Env$xdata),n=n,maType=maType,wilder=wilder)
   plot_object$add_frame(ylim=c(0,1),asp=0.2)
   plot_object$next_frame()
   lenv$xdata <- structure(rsi,.Dimnames=list(NULL, "rsi"))

Modified: pkg/R/replot.R
===================================================================
--- pkg/R/replot.R	2013-01-16 17:36:29 UTC (rev 601)
+++ pkg/R/replot.R	2013-01-18 05:29:19 UTC (rev 602)
@@ -4,7 +4,7 @@
   Env <- new.env()
   Env$frame <- frame
   Env$asp   <- asp
-  Env$usr   <- par("usr")
+  #Env$usr   <- par("usr")
   Env$xlim  <- xlim
   Env$ylim  <- ylim
   Env$pad1 <- -0 # bottom padding per frame



More information about the Quantmod-commits mailing list