I'm very new to R and Quantmod.
Is it possible to add an indicator like MACD and save the timeseries as csv?
Displaying the chart is very easy:
getSymbols("AAPL",src="yahoo")
barChart(AAPL)
addMACD()
But I want to add the indicators to the timeseries (save it as csv) and don't want to display it :)
Thanks!
How to do I tell the moving average to use the close-column? e <- cbind( AAPL, SMA( AAPL, n=50) )
and how do I add additional columns to csv?
You can just use cbind
to add the signal.
library(quantmod)
getSymbols("AAPL",src="yahoo")
d <- cbind( AAPL, MACD( AAPL ) )
write.csv(
data.frame( date=index(d), coredata(d) ),
row.names=FALSE,
file="tmp.csv"
)