[Quantmod-commits] r588 - in pkg: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Dec 19 04:44:40 CET 2012
Author: jryan
Date: 2012-12-19 04:44:39 +0100 (Wed, 19 Dec 2012)
New Revision: 588
Modified:
pkg/NAMESPACE
pkg/R/chart_Series.R
pkg/man/addMA.Rd
Log:
add_VMA and add_EVMA
Modified: pkg/NAMESPACE
===================================================================
--- pkg/NAMESPACE 2012-12-13 14:44:50 UTC (rev 587)
+++ pkg/NAMESPACE 2012-12-19 03:44:39 UTC (rev 588)
@@ -18,6 +18,8 @@
current.chob,
chart_Series, add_Series,
add_EMA,
+ add_EVWMA,
+ add_VMA,
add_WMA,
add_SMA,
add_DEMA,
Modified: pkg/R/chart_Series.R
===================================================================
--- pkg/R/chart_Series.R 2012-12-13 14:44:50 UTC (rev 587)
+++ pkg/R/chart_Series.R 2012-12-19 03:44:39 UTC (rev 588)
@@ -640,6 +640,24 @@
plot_object$add(exp,env=c(lenv, plot_object$Env),expr=TRUE)
plot_object
} # }}}
+# add_VMA {{{
+add_VMA <- function(w, ratio=1, on=1, col='green',...) {
+ lenv <- new.env()
+ lenv$add_wma <- function(x, w, ratio, col, ...) {
+ xdata <- x$Env$xdata
+ xsubset <- x$Env$xsubset
+ vma <- VMA(Cl(xdata), w=w, ratio=ratio)[xsubset]
+ lines(1:NROW(xdata[xsubset]), vma, col=col, ...)
+ }
+ mapply(function(name,value) { assign(name,value,envir=lenv) }, names(list(w=w,ratio=ratio,col=col,...)), list(w=w,ratio=ratio,col=col,...))
+ exp <- parse(text=gsub("list","add_wma",as.expression(substitute(list(x=current.chob(),w=w,ratio=ratio,col=col,...)))),
+ srcfile=NULL)
+ plot_object <- current.chob()
+ lenv$xdata <- VMA(Cl(plot_object$Env$xdata),w=w,ratio=ratio)
+ plot_object$set_frame(sign(on)*(abs(on)+1L))
+ plot_object$add(exp,env=c(lenv, plot_object$Env),expr=TRUE)
+ plot_object
+} # }}}
# add_DEMA {{{
add_DEMA <- function(n=10, on=1, col='pink', ...) {
lenv <- new.env()
@@ -677,6 +695,25 @@
plot_object$add(exp,env=c(lenv, plot_object$Env),expr=TRUE)
plot_object
} # }}}
+# add_EVWMA {{{
+add_EVWMA <- function(n=10, on=1, col='darkgrey', ...) {
+ lenv <- new.env()
+ lenv$add_evwma <- function(x, n, col, ...) {
+ xdata <- x$Env$xdata
+ xvo <- x$Env$vo
+ xsubset <- x$Env$xsubset
+ evwma <- EVWMA(Cl(xdata),xvo, n=n)[xsubset]
+ lines(1:NROW(xdata[xsubset]), evwma, col=col, ...)
+ }
+ mapply(function(name,value) { assign(name,value,envir=lenv) }, names(list(n=n,col=col,...)), list(n=n,col=col,...))
+ exp <- parse(text=gsub("list","add_evwma",as.expression(substitute(list(x=current.chob(),n=n,col=col,...)))),
+ srcfile=NULL)
+ plot_object <- current.chob()
+ lenv$xdata <- EVWMA(Cl(plot_object$Env$xdata),plot_object$Env$vo,n=n)
+ plot_object$set_frame(sign(on)*(abs(on)+1L))
+ plot_object$add(exp,env=c(lenv, plot_object$Env),expr=TRUE)
+ plot_object
+} # }}}
# add_GMMA {{{
add_GMMA <- function(short=c(3,5,8,10,12,15),long=c(30,35,40,45,50,60), on=1, col=c('yellow','brown'),...) {
#x, short = c(3, 5, 8, 10, 12, 15), long = c(30, 35,
Modified: pkg/man/addMA.Rd
===================================================================
--- pkg/man/addMA.Rd 2012-12-13 14:44:50 UTC (rev 587)
+++ pkg/man/addMA.Rd 2012-12-19 03:44:39 UTC (rev 588)
@@ -9,6 +9,8 @@
\alias{addDEMA}
\alias{add_DEMA}
\alias{addEVWMA}
+\alias{add_EVWMA}
+\alias{add_VMA}
\alias{addZLEMA}
\alias{add_VWAP}
\alias{add_GMMA}
More information about the Quantmod-commits
mailing list