All,

Here is some reproducible code that causes R to crash while running the MACD 
function in the TTR library.  The problem seems to be when the nSlow and nSig 
parameters are so large that the function is not able to calculate the moving 
average length denoted by nSig.  Now that I know what the problem is I can 
avoid it, but it would be nice if the MACD function returned an error instead 
of crashing R (unless its just my setup-R 2.15.1 64-bit win7).  Maybe someone 
can confirm for me by testing out the code below.

The first call to MACD should work as many times as you call it, as expected.  
However the second one causes problems because the data in temp is too short to 
product a moving average over 22 data points.  This crashes R almost always, 
but occasionally it does work once or twice.  That's why I used for loops to 
make my point.  First lets see if other people have the same results that I do. 
 If so, it would be nice if MACD produced an error instead of crashing R.

Thanks,

Roger


library(TTR)
temp <- 1:60
for (i in 1:10) x <- MACD(temp, nFast=15, nSlow=40, nSig=21) # Works fine
print("okay so far")
for (i in 1:10) x <- MACD(temp, nFast=15, nSlow=40, nSig=22) # Crashes R
print("bet you don't see this")


Roger J. Bos, CFA
Rothschild Asset Management, Inc.
Tel     +1 (212) 403-5471
Email roger....@rothschild.com<mailto:roger....@rothschild.com>
1251 Avenue of the Americas, NY, NY  10020


***************************************************************

This message is for the named person's use only. It may\...{{dropped:15}}

_______________________________________________
R-SIG-Finance@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should 
go.

Reply via email to