Random Forest Prediction Error Mismatch I am getting confusing results from the below model when backtesting.
The code splits the dataset into a training and a testing set (70/30) and as far as I can tell keeps the data separated so that the results found in t are in fact representative.
However, when testing the model against a real life progression of the timeseries data where the last days data (New Data.csv) is added to Data.csv as more information becomes available, the accuracy of the model does not hold up at all.
The mean OOB error is about 20% (which for my purposes is fine), yet the forecast of VarX for new.data has an error rate of 58% (half a years worth of daily data).
Is there anything about the below code that would explain the mismatch between the two predictions, and am I missing something else? 
Intuitively the prediction of new.data should be treated as just another OOB sample, but it clearly achieves nowhere near the same accuracy over time.
If I've been unclear let me know and I will do my best to rectify it.

Note the for loop in particular:
library(MASS)
library(randomForest)
library(caTools)
library(pROC)

##Storing the data set into DataFrame
DataFrame <- read.csv(file= "Data.csv", header = TRUE)
new.data <- read.csv(file = "New Data.csv", header = TRUE)

##check the structure and dimensions of the data
str(DataFrame)
dim(DataFrame)
str(new.data)
dim(new.data)

##check first couple of rows
head(DataFrame, 3)
head(new.data, 1)

##check summary of data
summary(DataFrame)
summary(new.data)

##check the number of unique values
apply(DataFrame,2,function(x) length(unique(x)))

##Sort numerical and categorical values
options(digits = 5)

cols <- c("VarX")
for (i in cols) {
  DataFrame[,i] = as.factor(DataFrame[,i])
}
cols2 <- c("Var1", "Var2", "Var3", "Var4", "Var5", "Var6", "Var7")
for (i in cols2) {
  DataFrame[,i] = as.numeric(DataFrame[,i])
  new.data[,i] = as.numeric(new.data[,i])
}
str(DataFrame)
str(new.data)

Accuracy <- matrix(data = NA, nrow = 100, ncol = 1)
Output <- matrix(data = NA, nrow = 100, ncol = 2)

for (i in 1:100) {

  ##create the test and train data set
  ind <- sample.split(Y = DataFrame$VarX, SplitRatio = 0.7)
  trainDF <- DataFrame[ind,]
  testDF <- DataFrame[!ind,]

  ##Fitting the model
  modelRandom <- randomForest(VarX~., data = trainDF, mtry = 2, ntree = 200
                            , importance = TRUE)

  ##predictions
  PredictionsWithClass <- predict(modelRandom, testDF, type = 'class')
  t <- table(predictions=PredictionsWithClass, actual = testDF$VarX)

  ##accuracy metric
  Accuracy[i,] <- sum(diag(t))/sum(t)

  Output[i,] <- predict(modelRandom, new.data, type = 'prob')
}

##Calculate accuracy and predictions
colnames(Accuracy) <- c("Accuracy %")
colnames(Output) <- c("Down", "Up")

summary(Accuracy)
summary(Output)

 A: If I understand correctly, you want to design a model which predicts best future outcomes. If so, you are not in the classical framework of machine learning, where one wants to predict $Y$ from $X$ where $Y$ given $X$ follows the same distribution as a sample of observations $(X_1,Y_1),...,(X_n,Y_n)$. In your case, the distribution might have changed since the previous observations, because of the time dependency. 
It seems to be the case when one looks at the graph you provided, showing the evolution of the accuracy over time. I guess you trained the random forest on the data from beginning Nov 16 (because of the 100% accuracy) and then tested it on each of the following weeks. One can see that the prediction accuracy degrades all the more as the data is more advanced in time. This is a clear indication that the distribution is time-dependent.
Here are two recommendations to improve your model.
1. Tuning the parameters of the model
I am surprised that you do not look for optimal parameters for your random forest. This algorithm has parameters whose values depend on the problem you consider. In particular, the depth of the trees has to be optimized, because too deep trees will lead to overfitting. It seems like the R-package you use builds trees with maximal depth by default.
Classical approach: a grid-search. To tune the parameters is to test several values for the parameters (for example on a grid of values) and select the values which achieve the highest accuracy on the test set.
A 100% accuracy on the training set is a sign that your model overfits.
2. Using the accuracy on a future test set to assess the performance of the model
As you mentioned it, the classical approach is to randomly split the training set into two parts and use the accuracy on the test set to assess the performance of the model. 
In your case, since you want to maximize the prediction accuracy on future outcomes, I recommend that you rather split your training data temporally, ie. that you train the model on the first 70% observations (sorted chronologically) and test it on the last 30%. If you perform a grid-search (which I recommend), using this criterion will select the best set of parameters for future prediction.
