Hi,
I'm wondering if there are any know limitations with the TTR
chaikinVolatility function I should be aware of. I've got a small
application I've been writing in R that uses it. I debugged the app
using weekly data for the SPX, DJI, Nasdaq and Russell going back as
far as TradeStation would give me data. Everything worked great.
However when I switched to SPX daily data the indicator fails for the
first 1/3 to 1/2 of the data. (Roughly 12400 days) Looking into the
data output of the indicator I see this:
[4465] 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
[4483] 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
[4501] 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 Inf Inf Inf Inf Inf Inf Inf
[4519] Inf Inf Inf Inf Inf Inf 3.83 1.75 0.78 0.46
0.35 0.20 0.15 0.12 0.12 0.12 0.09 0.03
[4537] 0.01 0.05 0.03 0.02 0.00 -0.04 -0.03 -0.06 -0.07 -0.09
-0.13 -0.12 -0.07 -0.02 -0.02 -0.01 -0.02 0.01
[4555] -0.01 -0.01 -0.01 -0.01 0.04 0.08 0.11 0.09 0.04 0.06
0.06 0.10 0.08 0.07 0.05 0.07 0.04 -0.03
After the indicator starts working it continues to work, but it's
all 0.00 back to the beginning except for these few Inf's in the
middle.
When I broke the code out to try to debug it before I wrote this
email I got somewhat different results with NaN's:
The data came from TradeStation. It looks OK to me visually. The
code stub I'm using follows. I could possibly post the data somewhere
if necessary.
Thanks,
Mark
require(chron)
require(ggplot2)
require(quantmod)
require(reshape)
require(TTR)
AbsLookback = 13
TradeSystem = read.csv("C:\\MiningData\\SPX_Daily.txt",header=TRUE)
#TradeSystem = read.csv("C:\\MiningData\\SPX_Weekly.txt",header=TRUE)
#TradeSystem = read.csv("C:\\MiningData\\INDU_Weekly.txt",header=TRUE)
#TradeSystem = read.csv("C:\\MiningData\\NDX_Weekly.txt",header=TRUE)
#TradeSystem = read.csv("C:\\MiningData\\RUT_Weekly.txt",header=TRUE)
TradeSystem$MyDate = as.Date(TradeSystem$Date, "%m/%d/%Y")
CVol = data.frame(chaikinVolatility(TradeSystem[,c("High","Low")],
n=AbsLookback))
names(CVol)[1]="ChVol"
TradeSystem$ChVol = round(CVol$ChVol, 2)