I am trying to forecast future price using supervised machine learning. My logic is to take open and close price from t, t-1, t-2 and t-3 period to predict future close price in the period t+1,t+3 and t+5
library(quantmod)
symbol= getSymbols("AAPL",from="2010-03-01", auto.assign=F)
close<-Cl(symbol)
open<-Op(symbol)
lc1<-lag(close)
lc2<-lag(close,2)
lc3<-lag(close,3)
lo1<-lag(open)
lo2<-lag(open,2)
lo3<-lag(open,3)
X<-cbind(close,open,lc1,lc2,lc3,lo1,lo2,lo3)
Y<-need to assign close price for t+1,t+3 and t+5
I have created feature vectors using lag function for period 0,1,2 and 3 but my question is how to I assign target variable for t+1, t+3 and t+5 periods.