# momentum(x, n=1, na.pad=TRUE)
# n is the number of periods
# na.pad asks whether to keep the first several observations
library(TTR)
x <- getYahooData("IBM")
tail(x[,1:4],3)
diff<-momentum(x[,"Close"])
head(diff,3)
diff2<-momentum(x[,"Close"],2)
head(diff2,4)


