[Candlesticks-commits] r23 - in pkg: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Jul 21 11:06:17 CEST 2012


Author: wotuzu17
Date: 2012-07-21 11:06:17 +0200 (Sat, 21 Jul 2012)
New Revision: 23

Added:
   pkg/R/nextCandlePosition.R
   pkg/man/nextCandlePosition.Rd
Modified:
   pkg/DESCRIPTION
   pkg/NAMESPACE
   pkg/man/CSPDarkCloudCover.Rd
   pkg/man/CSPPiercingPattern.Rd
Log:
added nextCandlePosition

Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2012-07-10 09:42:43 UTC (rev 22)
+++ pkg/DESCRIPTION	2012-07-21 09:06:17 UTC (rev 23)
@@ -1,12 +1,12 @@
 Package: candlesticks
 Type: Package
 Title: Candlestick Pattern Recognition
-Version: 0.1-16
-Date: 2012-05-22
+Version: 0.1-17
+Date: 2012-07-21
 Author: Andreas Voellenklee
 Maintainer: Andreas Voellenklee <wotuzu17 at gmail.com>
 Depends: R (>= 2.13), xts (>= 0.8-2), quantmod (>= 0.3-17), TTR (>= 0.21-0)
-Description: Filter Japanese Candlestick Patterns like Doji, Engulfing, Harami, etc. out of OHLC price data. Still in heavy development.
+Description: Filter Japanese Candlestick Patterns like Doji, Engulfing, Harami, etc. out of OHLC price data.
 URL: https://r-forge.r-project.org/projects/candlesticks/
 License: GPL-3
 LazyLoad: yes

Modified: pkg/NAMESPACE
===================================================================
--- pkg/NAMESPACE	2012-07-10 09:42:43 UTC (rev 22)
+++ pkg/NAMESPACE	2012-07-21 09:06:17 UTC (rev 23)
@@ -43,4 +43,5 @@
 export(DonchianChannel2)
 export(is.HL)
 export(is.OC)
+export(nextCandlePosition)
 

Added: pkg/R/nextCandlePosition.R
===================================================================
--- pkg/R/nextCandlePosition.R	                        (rev 0)
+++ pkg/R/nextCandlePosition.R	2012-07-21 09:06:17 UTC (rev 23)
@@ -0,0 +1,16 @@
+nextCandlePosition <- function(TS) {
+  if (!is.OC(TS)) {
+    stop("Price series must contain Open and Close.")
+  }
+  NextOp <- as.xts(Next(Op(TS)))
+  NextCl <- as.xts(Next(Cl(TS)))
+  HigherOpen <- NextOp > Op(TS)
+  LowerOpen <- NextOp < Op(TS)
+  HigherClose <- NextCl > Cl(TS)
+  LowerClose <- NextCl < Cl(TS)
+  NextWhite <- NextOp < NextCl
+  NextBlack <- NextOp > NextCl
+  result <- reclass(cbind(HigherOpen, LowerOpen, HigherClose, LowerClose, NextWhite, NextBlack), TS)
+  colnames(result) <- c("HigherOpen", "LowerOpen","HigherClose","LowerClose", "White", "Black")
+  return(result)
+}
\ No newline at end of file

Modified: pkg/man/CSPDarkCloudCover.Rd
===================================================================
--- pkg/man/CSPDarkCloudCover.Rd	2012-07-10 09:42:43 UTC (rev 22)
+++ pkg/man/CSPDarkCloudCover.Rd	2012-07-21 09:06:17 UTC (rev 23)
@@ -32,7 +32,7 @@
   
   # filter dark cloud covers that occur in uptrends.
   # the lag of 2 periods of the time series for trend detection
-  # ensures that the uptrend is active \emph{before} the
+  # ensures that the uptrend is active *before* the
   # dark cloud cover occurs.
   CSPDarkCloudCover(YHOO) & TrendDetectionChannel(lag(YHOO,k=2))[,"UpTrend"]
 }

Modified: pkg/man/CSPPiercingPattern.Rd
===================================================================
--- pkg/man/CSPPiercingPattern.Rd	2012-07-10 09:42:43 UTC (rev 22)
+++ pkg/man/CSPPiercingPattern.Rd	2012-07-21 09:06:17 UTC (rev 23)
@@ -32,7 +32,7 @@
   
   # filter piercing patterns that occur in downtrends.
   # the lag of 2 periods of the time series for trend detection
-  # ensures that the uptrend is active \emph{before} the
+  # ensures that the uptrend is active *before* the
   # dark cloud cover occurs.
   CSPPiercingPattern(YHOO) & TrendDetectionChannel(lag(YHOO,k=2))[,"DownTrend"]
 }

Added: pkg/man/nextCandlePosition.Rd
===================================================================
--- pkg/man/nextCandlePosition.Rd	                        (rev 0)
+++ pkg/man/nextCandlePosition.Rd	2012-07-21 09:06:17 UTC (rev 23)
@@ -0,0 +1,37 @@
+\name{nextCandlePosition}
+\alias{nextCandlePosition}
+\title{Position and color of the next candle in a OC price series}
+\description{Examines open and close price of the following candle relative to the close price of the current candle. Also returns the color of the folling candle.}
+\usage{nextCandlePosition(TS)}
+\arguments{
+  \item{TS}{xts Time Series containing Open and Close Prices}
+}
+\details{
+  Sometimes it is suggested to wait for a confirmation in the form of a higher/lower following close and/or a white/black candle before conisdering trading the pattern. This function compares the price levels and returns a xts object with columns of boolean values for each contition.
+}
+\value{
+  A xts object containing the columns:
+  \item{HigherOpen}{TRUE if following candle opens higher than current close}
+  \item{LowerOpen}{TRUE if following candle opens lower than current close}
+  \item{HigherClose}{TRUE if following candle closes higher than current close}
+  \item{LowerClose}{TRUE if following candle closes lower than current close}
+  \item{White}{TRUE if following candle is white (Cl>Op)}
+  \item{Black}{TRUE if following candle is black (Cl<Op)}
+}
+\note{
+  This function uses the Next function of the \pkg{quantmod} package.
+}
+\seealso{
+  \code{\link{Next}}
+}
+\examples{
+\dontrun{
+# filter for inverted hammers in uptrends that is followed by a lower close the next day
+getSymbols('YHOO', adjust=TRUE)
+CSPInvertedHammer(YHOO) & 
+  TrendDetectionChannel(YHOO)[,"UpTrend"] & 
+  nextCandlePosition(YHOO)[,"LowerClose"]
+}
+}
+\author{Andreas Voellenklee}
+\keyword{}



More information about the Candlesticks-commits mailing list