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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jan 19 12:14:51 CET 2012


Author: wotuzu17
Date: 2012-01-19 12:14:49 +0100 (Thu, 19 Jan 2012)
New Revision: 6

Added:
   pkg/R/CSPTasukiGap.R
   pkg/man/CSPTasukiGap.Rd
Modified:
   pkg/DESCRIPTION
   pkg/NAMESPACE
   pkg/R/CSPGap.R
   pkg/R/LagFunctions.R
   pkg/man/CSPGap.Rd
Log:
fixed lag functions and added CSPTasukiGap

Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2012-01-16 09:52:53 UTC (rev 5)
+++ pkg/DESCRIPTION	2012-01-19 11:14:49 UTC (rev 6)
@@ -1,8 +1,8 @@
 Package: candlesticks
 Type: Package
 Title: Candlestick Pattern Recognition
-Version: 0.1-5
-Date: 2012-01-16
+Version: 0.1-6
+Date: 2012-01-19
 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)

Modified: pkg/NAMESPACE
===================================================================
--- pkg/NAMESPACE	2012-01-16 09:52:53 UTC (rev 5)
+++ pkg/NAMESPACE	2012-01-19 11:14:49 UTC (rev 6)
@@ -21,6 +21,7 @@
 export(CSPShortCandleBody)
 export(CSPStar)
 export(CSPStomache)
+export(CSPTasukiGap)
 export(CSPThreeBlackCrows)
 export(CSPThreeInside)
 export(CSPThreeOutside)

Modified: pkg/R/CSPGap.R
===================================================================
--- pkg/R/CSPGap.R	2012-01-16 09:52:53 UTC (rev 5)
+++ pkg/R/CSPGap.R	2012-01-19 11:14:49 UTC (rev 6)
@@ -9,7 +9,7 @@
     UPGAP <- eval(as.xts(apply(LAGTSOC,1,max)) < as.xts(apply(TSOC,1,min)))
     DOWNGAP <- eval(as.xts(apply(LAGTSOC,1,min)) > as.xts(apply(TSOC,1,max)))    
   }
-  else {
+  else if (ignoreShadows==FALSE) {
     if (!is.OHLC(TS)) {
       stop("Price series must contain Open, High, Low and Close.")
     }

Added: pkg/R/CSPTasukiGap.R
===================================================================
--- pkg/R/CSPTasukiGap.R	                        (rev 0)
+++ pkg/R/CSPTasukiGap.R	2012-01-19 11:14:49 UTC (rev 6)
@@ -0,0 +1,21 @@
+CSPTasukiGap <- function (TS) {
+  if (!is.OHLC(TS)) {
+    stop("Price series must contain Open, High, Low and Close.")
+  }
+  LAG2TS <- LagOHLC(TS, k=2)
+  LAG1TS <- LagOHLC(TS, k=1)
+  GAP1 <- CSPGap(LAG1TS, ignoreShadows=FALSE)
+  UTG <- eval(Op(LAG2TS) < Cl(LAG2TS) &   # 1st candle: white
+    GAP1[,1] &                            # Up Gap btwn 1st and 2nd candle
+    Op(LAG1TS) < Cl(LAG1TS) &             # 2nd candle: white
+    Op(TS) < Cl(LAG1TS) & Op(TS) > Op(LAG1TS)  & # 3rd candle opens within 2nd candle's body
+    Cl(TS) < Lo(LAG1TS) & Cl(TS) > Hi(LAG2TS))   # 3rd candle closes within gap of 1st and 2nd candle
+  DTG <- eval(Op(LAG2TS) > Cl(LAG2TS) &   # 1st candle: black
+    GAP1[,2] &                            # Down Gap btwn 1st and 2nd candle
+    Op(LAG1TS) > Cl(LAG1TS) &             # 2nd candle: black
+    Op(TS) > Cl(LAG1TS) & Op(TS) < Op(LAG1TS)  & # 3rd candle opens within 2nd candle's body
+    Cl(TS) > Hi(LAG1TS) & Cl(TS) < Lo(LAG2TS))   # 3rd candle closes within gap of 1st and 2nd candle
+  result <- cbind(UTG, DTG)
+  colnames(result) <- c("UpsideTasukiGap", "DownsideTasukiGap")
+  return (result)
+}
\ No newline at end of file

Modified: pkg/R/LagFunctions.R
===================================================================
--- pkg/R/LagFunctions.R	2012-01-16 09:52:53 UTC (rev 5)
+++ pkg/R/LagFunctions.R	2012-01-19 11:14:49 UTC (rev 6)
@@ -19,7 +19,7 @@
   if (!is.OHLC(TS)) {
     stop("Price series must contain Open, High, Low and Close.")
   }
-  result <- cbind(Lag(Op(TS),k), Lag(Hi(TS),k), Lag(Lo(TS),k), Lag(Cl(TS),k))
+  result <- cbind(lag(Op(TS),k), lag(Hi(TS),k), lag(Lo(TS),k), lag(Cl(TS),k))
   colnames(result) <- c(
     paste(colnames(Op(TS)),k,sep='.Lag.'),
     paste(colnames(Hi(TS)),k,sep='.Lag.'),
@@ -32,7 +32,7 @@
   if (!is.OC(TS)) {
     stop("Price series must contain Open and Close.")
   }
-  result <- cbind(Lag(Op(TS),k), Lag(Cl(TS),k))
+  result <- cbind(lag(Op(TS),k), lag(Cl(TS),k))
   colnames(result) <- c(
     paste(colnames(Op(TS)),k,sep='.Lag.'),
     paste(colnames(Cl(TS)),k,sep='.Lag.'))

Modified: pkg/man/CSPGap.Rd
===================================================================
--- pkg/man/CSPGap.Rd	2012-01-16 09:52:53 UTC (rev 5)
+++ pkg/man/CSPGap.Rd	2012-01-19 11:14:49 UTC (rev 6)
@@ -1,6 +1,8 @@
 \name{CSPGap}
 \alias{CSPGap}
 \alias{Gap}
+\alias{RisingWindow}
+\alias{FallingWindow}
 \title{Gap Candlestick Pattern}
 \description{Look for price gaps between two candles in a OHLC price series}
 \usage{CSPGap(TS, ignoreShadows=FALSE)}
@@ -20,7 +22,7 @@
 }
 \author{Andreas Voellenklee}
 \references{}
-\note{}
+\note{The up/down gaps are also called \emph{Rising Window}/\emph{Falling Window}}
 \seealso{}
 \examples{
 \dontrun{

Added: pkg/man/CSPTasukiGap.Rd
===================================================================
--- pkg/man/CSPTasukiGap.Rd	                        (rev 0)
+++ pkg/man/CSPTasukiGap.Rd	2012-01-19 11:14:49 UTC (rev 6)
@@ -0,0 +1,42 @@
+\name{CSPTasukiGap}
+\alias{CSPTasukiGap}
+\alias{TasukiGap}
+\alias{UpsideTasukiGap}
+\alias{DownsideTasukiGap}
+\title{Upside/Downside Tasuki Gap Candlestick Pattern}
+\description{Look for Upside/Downside Tasuki Gap Pattern in a OHLC price series}
+\usage{CSPTasukiGap(TS)}
+\arguments{
+  \item{TS}{xts Time Series containing OHLC prices}
+}
+\details{
+Number of candle lines: \bold{3}\cr\cr
+\emph{Upside Tasuki Gap:}\cr
+The market is in uptrend. The first candle of the formation is a white candle, followed by another white candle that has gapped above the high of the first candle. The third candle is a black candle that opens within the body of the second candle and closes within the gap between the first and second candle.\cr\cr
+\emph{Downside Tasuki Gap:}\cr
+The market is in downtrend. The first candle of the formation is a black candle, followed by another black candle that has gapped below the low of the first candle. The third candle is a white candle that opens within the body of the second candle and closes within the gap between the first and second candle.\cr\cr
+}
+\value{
+  A xts object containing the columns:
+  \item{UpsideTasukiGap}{TRUE if Upside Tasuki Gap pattern detected}
+  \item{DownsideTasukiGap}{TRUE if Downside Tasuki Gap pattern detected}
+}
+\author{Andreas Voellenklee}
+\references{
+The following site(s) were used to code/document this indicator:\cr
+  \url{http://www.investopedia.com/terms/u/upside-tasuki-gap.asp#axzz1jtuDsM6i}\cr
+  \url{http://www.investopedia.com/terms/d/downside-tasuki-gap.asp#axzz1jtuDsM6i}\cr
+  \url{http://thepatternsite.com/UpsideTasukiGap.html}\cr
+  \url{http://thepatternsite.com/DownsideTasukiGap.html}\cr
+}
+\note{Trend detection prior to the formation is not implemented yet}
+\seealso{
+\code{\link{CSPGap}}
+}
+\examples{
+\dontrun{
+getSymbols("SSRI", adjust=TRUE)
+CSPTasukiGap(SSRI)
+}
+}
+\keyword{}



More information about the Candlesticks-commits mailing list