[Candlesticks-commits] r28 - in pkg: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Sep 15 23:17:43 CEST 2013


Author: wotuzu17
Date: 2013-09-15 23:17:43 +0200 (Sun, 15 Sep 2013)
New Revision: 28

Modified:
   pkg/DESCRIPTION
   pkg/R/CSPDoji.R
   pkg/R/CSPGap.R
   pkg/R/CSPHammer.R
   pkg/R/CSPInvertedHammer.R
   pkg/R/CSPMarubozu.R
Log:
implemented pmax(Op(TS), Cl(TS)) instead of as.xts(apply(...)) in 5 CSP functions to avoid timezone issues.

Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2013-07-24 07:25:35 UTC (rev 27)
+++ pkg/DESCRIPTION	2013-09-15 21:17:43 UTC (rev 28)
@@ -1,7 +1,7 @@
 Package: candlesticks
 Type: Package
 Title: Candlestick Pattern Recognition
-Version: 0.2-2
+Version: 0.2-3
 Date: 2013-07-24
 Author: Andreas Voellenklee
 Maintainer: Andreas Voellenklee <wotuzu17 at gmail.com>

Modified: pkg/R/CSPDoji.R
===================================================================
--- pkg/R/CSPDoji.R	2013-07-24 07:25:35 UTC (rev 27)
+++ pkg/R/CSPDoji.R	2013-09-15 21:17:43 UTC (rev 28)
@@ -4,8 +4,8 @@
   }
   BL <- abs(Cl(TS)-Op(TS))
   CL <- Hi(TS)-Lo(TS)
-  BodyHi <- as.xts(apply(cbind(Op(TS),Cl(TS)),1,max))
-  BodyLo <- as.xts(apply(cbind(Op(TS),Cl(TS)),1,min))
+  BodyHi <- pmax(Op(TS), Cl(TS))
+  BodyLo <- pmin(Op(TS), Cl(TS))
   Doji <- reclass(BL < CL* maxbodyCL, TS)
   DFDoji <- reclass(Doji & (Hi(TS)-BodyHi <= CL* maxshadowCL), TS)
   GSDoji <- reclass(Doji & (BodyLo-Lo(TS) <= CL* maxshadowCL), TS)

Modified: pkg/R/CSPGap.R
===================================================================
--- pkg/R/CSPGap.R	2013-07-24 07:25:35 UTC (rev 27)
+++ pkg/R/CSPGap.R	2013-09-15 21:17:43 UTC (rev 28)
@@ -6,8 +6,8 @@
     LAGTS <- LagOC(TS, k=1)
     TSOC <- cbind(Op(TS), Cl(TS))
     LAGTSOC <- cbind(Op(LAGTS), Cl(LAGTS))
-    UPGAP <- reclass( as.xts(apply(LAGTSOC,1,max)) < as.xts(apply(TSOC,1,min)) , TS)
-    DOWNGAP <- reclass( as.xts(apply(LAGTSOC,1,min)) > as.xts(apply(TSOC,1,max)), TS)
+    UPGAP <- reclass( pmax(Op(LAGTSOC), Cl(LAGTSOC)) < pmin(Op(TSOC), Cl(TSOC)) , TS)
+    DOWNGAP <- reclass( pmin(Op(LAGTSOC), Cl(LAGTSOC)) > pmax(Op(TSOC), Cl(TSOC)), TS)
   }
   else if (ignoreShadows==FALSE) {
     if (!is.OHLC(TS)) {

Modified: pkg/R/CSPHammer.R
===================================================================
--- pkg/R/CSPHammer.R	2013-07-24 07:25:35 UTC (rev 27)
+++ pkg/R/CSPHammer.R	2013-09-15 21:17:43 UTC (rev 28)
@@ -3,8 +3,8 @@
     stop("Price series must contain Open, High, Low and Close.")
   }
   CL <- Hi(TS)-Lo(TS)
-  BodyHi <- as.xts(apply(cbind(Op(TS),Cl(TS)),1,max))
-  BodyLo <- as.xts(apply(cbind(Op(TS),Cl(TS)),1,min))
+  BodyHi <- pmax(Op(TS),Cl(TS))
+  BodyLo <- pmin(Op(TS),Cl(TS))
   Hammer <- reclass(
     BodyLo-Lo(TS) > CL*minlowershadowCL &   # lower shadow greater than lowershadowCL*CandleLength
     Hi(TS)- BodyHi <= CL*maxuppershadowCL & # upper shadow missing or very short

Modified: pkg/R/CSPInvertedHammer.R
===================================================================
--- pkg/R/CSPInvertedHammer.R	2013-07-24 07:25:35 UTC (rev 27)
+++ pkg/R/CSPInvertedHammer.R	2013-09-15 21:17:43 UTC (rev 28)
@@ -3,8 +3,8 @@
     stop("Price series must contain Open, High, Low and Close.")
   }
   CL <- Hi(TS)-Lo(TS)
-  BodyHi <- as.xts(apply(cbind(Op(TS),Cl(TS)),1,max))
-  BodyLo <- as.xts(apply(cbind(Op(TS),Cl(TS)),1,min))
+  BodyHi <- pmax(Op(TS),Cl(TS))
+  BodyLo <- pmin(Op(TS),Cl(TS))
   InvertedHammer <- reclass(
     Hi(TS)- BodyHi > CL*minuppershadowCL &   # upper shadow greater than lowershadowCL*CandleLength
     BodyLo- Lo(TS) <= CL*maxlowershadowCL &  # lower shadow missing or very short

Modified: pkg/R/CSPMarubozu.R
===================================================================
--- pkg/R/CSPMarubozu.R	2013-07-24 07:25:35 UTC (rev 27)
+++ pkg/R/CSPMarubozu.R	2013-09-15 21:17:43 UTC (rev 28)
@@ -5,9 +5,9 @@
   LongCandle = CandleBodyLength(TS)[,"absCandleBodyLength"] > 
     ATR(cbind(Hi(TS), Lo(TS), Cl(TS)), n=n, maType="SMA")[,"atr"]*ATRFactor
   CL <- Hi(TS)-Lo(TS)
-  BodyHi <- as.xts(apply(cbind(Op(TS),Cl(TS)),1,max))
-  BodyLo <- as.xts(apply(cbind(Op(TS),Cl(TS)),1,min))
-  ShortShadow = Hi(TS)-BodyHi <= CL*maxuppershadowCL & BodyLo-Lo(TS) <= CL*maxlowershadowCL
+  BodyHi <- pmax(Op(TS),Cl(TS))
+  BodyLo <- pmin(Op(TS),Cl(TS))
+  ShortShadow <- Hi(TS)-BodyHi <= CL*maxuppershadowCL & BodyLo-Lo(TS) <= CL*maxlowershadowCL
   WhiteMarubozu <- reclass( LongCandle & ShortShadow & Op(TS) < Cl(TS), TS)
   BlackMarubozu <- reclass( LongCandle & ShortShadow & Op(TS) > Cl(TS), TS)
   result <- cbind(WhiteMarubozu, BlackMarubozu)



More information about the Candlesticks-commits mailing list