How To Use Vector Autoregression Models In Predicting Price Using R?

In a previous post, we tried to model the daily and the weekly candle with an Elman Neural Network. The results were not encouraging. The problem that we face with neural networks is that most of the time these networks get stuck up with a local minima. So everytime you run the model, it will give you a different result. Another major problem that we faced was the time being taken by R to make calculation. Time was around 20 minutes which is excessively if you want to trade on the intraday timeframe.

R Is A Powerful Machine Learning And Data Analysis Software

You must be familiar with R software by now. R is a powerful machine learning and data analysis software that is open source and can be downloaded freely. MT4 MQL4 language just lacks the power of R. MQL4 is just good for making a few indicators and EAs. What we can do is connect R with MT4 and then use the power of R to make the predictions. Python is another powerful machine learning and data analysis language that you should learn.

VAR Model For Predicting Next Few Candles Infographic

In this post we are going to discuss how we can use Vector Autoregression Models in predicting the next candle. R package that we will use for this is known as VaR package. This package calculates 3 models: Vector Autoregression Model (VAR), Structured Vector Autoregression Model (SVAR) and Vector Error Correction Model (VECM). In this post we are not going to discuss SVAR and VECM model. We will discuss these models when I write the post on how to model cointegration. Infographic below gives a brief overview of how to make these predictions.

VAR Model Price Prediction

If you don’t know what Vector Autoregression is, you should watch this video below that explains the VAR model:

The problem that we face with most time series models is that most of the time we are only using the close price in making the predictions. In a VAR model we can use Open, High, Low and Close in one autoregressive model that then is used to predict Open, High, Low and Close for the next few candles. So let’s start and see how good are the predictions. If we calculate correlation of Open, High, Low and Close with each other we get values above 0.9 which is an indication that these variables are highly correlated.

> # Import the csv file
> quotes <- read.csv("E:/MarketData/GBPUSD10080.csv", header=FALSE)
> 
> 
> x <-nrow(quotes)
> 
> #correlation of High and Close price
> 
> cor(quotes[,4], quotes[,6])
[1] 0.9958719
> 
> #correlation of Low and Close price
> 
> cor(quotes[,5], quotes[,6])
[1] 0.9968037

You can see the high correlation between Open, High, Low and Close. We already know this from our trading experience that Open, High, Low and Close predict each other. So we will develop a VAR model in this post uses Open, High, Low, Close and the Volume as the endogenous variables.

Weekly Candle Prediction With VAR Model

> # Import the csv file
> quotes <- read.csv("E:/MarketData/GBPUSD10080.csv", header=FALSE)
> 
> 
> x <-nrow(quotes)
> 
> #convert the data frame into an xts object
> quotes1 <- as.ts(quotes)
> 
> tail(quotes1)
          V1 V2      V3      V4      V5      V6     V7
[1021,] 1021  1 1.29514 1.34811 1.28507 1.31937 767484
[1022,] 1022  1 1.31973 1.33151 1.30651 1.30971 613903
[1023,] 1023  1 1.31467 1.33015 1.30570 1.32313 565129
[1024,] 1024  1 1.32262 1.33719 1.30216 1.30762 513608
[1025,] 1025  1 1.30809 1.30969 1.29084 1.29100 355199
[1026,] 1026  1 1.29274 1.29400 1.29007 1.29318   6854
> 
> lr <- quotes1[(x-1000):(x-2),3:7]
> 
> 
> #install vars package
> 
> library(vars)
Loading required package: MASS
Loading required package: strucchange
Loading required package: zoo

Attaching package: ‘zoo’

The following objects are masked from ‘package:base’:

    as.Date, as.Date.numeric

Loading required package: sandwich
Loading required package: urca
Loading required package: lmtest
> 
> summary(VAR(lr, p=10, type="both"))

VAR Estimation Results:
========================= 
Endogenous variables: V3, V4, V5, V6, V7 
Deterministic variables: both 
Sample size: 989 
Log Likelihood: 1362.321 
Roots of the characteristic polynomial:
0.9932 0.9694 0.956 0.8815 0.8815 0.8686 0.8686 0.8622 0.8622 0.8616 0.8616 0.8526 0.8526 0.8138 0.8138 0.8131 0.8131 0.8122 0.8122 0.7956 0.7956 0.7944 0.7944 0.789 0.7872 0.7872 0.7772 0.7772 0.7746 0.7746 0.7659 0.7659 0.7577 0.7577 0.7575 0.7575 0.7493 0.7493 0.7477 0.7477 0.7297 0.7297 0.7205 0.6671 0.6671 0.6554 0.6554 0.6389 0.6389 0.3242
Call:
VAR(y = lr, p = 10, type = "both")


Estimation results for equation V3: 
=================================== 
V3 = V3.l1 + V4.l1 + V5.l1 + V6.l1 + V7.l1 + V3.l2 + V4.l2 + V5.l2 + V6.l2 + V7.l2 + V3.l3 + V4.l3 + V5.l3 + V6.l3 + V7.l3 + V3.l4 + V4.l4 + V5.l4 + V6.l4 + V7.l4 + V3.l5 + V4.l5 + V5.l5 + V6.l5 + V7.l5 + V3.l6 + V4.l6 + V5.l6 + V6.l6 + V7.l6 + V3.l7 + V4.l7 + V5.l7 + V6.l7 + V7.l7 + V3.l8 + V4.l8 + V5.l8 + V6.l8 + V7.l8 + V3.l9 + V4.l9 + V5.l9 + V6.l9 + V7.l9 + V3.l10 + V4.l10 + V5.l10 + V6.l10 + V7.l10 + const + trend 

         Estimate Std. Error t value Pr(>|t|)    
V3.l1   1.246e-02  3.475e-02   0.359  0.72003    
V4.l1  -7.164e-02  1.733e-02  -4.133  3.9e-05 ***
V5.l1   4.368e-02  1.588e-02   2.751  0.00606 ** 
V6.l1   1.008e+00  1.469e-02  68.654  < 2e-16 ***
V7.l1   1.151e-09  2.400e-09   0.479  0.63184    
V3.l2  -1.031e-01  3.476e-02  -2.967  0.00309 ** 
V4.l2   3.383e-02  1.760e-02   1.922  0.05485 .  
V5.l2  -1.707e-02  1.620e-02  -1.054  0.29232    
V6.l2  -1.327e-02  3.625e-02  -0.366  0.71427    
V7.l2  -2.974e-09  3.184e-09  -0.934  0.35046    
V3.l3  -3.677e-02  3.491e-02  -1.053  0.29243    
V4.l3  -1.234e-02  1.762e-02  -0.700  0.48379    
V5.l3   2.445e-02  1.638e-02   1.493  0.13578    
V6.l3   9.166e-02  3.611e-02   2.538  0.01130 *  
V7.l3   1.728e-09  3.179e-09   0.544  0.58689    
V3.l4   9.987e-02  3.480e-02   2.870  0.00420 ** 
V4.l4   9.725e-05  1.764e-02   0.006  0.99560    
V5.l4   2.562e-02  1.651e-02   1.552  0.12110    
V6.l4   3.591e-02  3.627e-02   0.990  0.32240    
V7.l4   2.094e-10  3.191e-09   0.066  0.94769    
V3.l5  -2.444e-02  3.485e-02  -0.701  0.48332    
V4.l5   1.417e-02  1.767e-02   0.802  0.42267    
V5.l5  -4.530e-02  1.654e-02  -2.738  0.00630 ** 
V6.l5  -1.115e-01  3.637e-02  -3.065  0.00224 ** 
V7.l5  -1.419e-09  3.206e-09  -0.442  0.65828    
V3.l6  -5.473e-02  3.491e-02  -1.567  0.11735    
V4.l6  -1.870e-02  1.774e-02  -1.054  0.29220    
V5.l6  -1.664e-02  1.651e-02  -1.008  0.31382    
V6.l6   6.187e-02  3.657e-02   1.692  0.09096 .  
V7.l6   1.650e-10  3.213e-09   0.051  0.95905    
V3.l7   4.949e-02  3.508e-02   1.411  0.15860    
V4.l7  -2.370e-02  1.821e-02  -1.301  0.19359    
V5.l7  -4.293e-03  1.667e-02  -0.258  0.79680    
V6.l7   8.131e-02  3.644e-02   2.232  0.02588 *  
V7.l7   1.186e-09  3.255e-09   0.364  0.71573    
V3.l8  -1.002e-01  3.488e-02  -2.872  0.00418 ** 
V4.l8   1.292e-02  1.823e-02   0.709  0.47853    
V5.l8   9.711e-03  1.646e-02   0.590  0.55544    
V6.l8  -3.283e-02  3.659e-02  -0.897  0.36984    
V7.l8  -8.295e-11  3.258e-09  -0.025  0.97969    
V3.l9  -8.366e-03  3.490e-02  -0.240  0.81059    
V4.l9   1.550e-04  1.798e-02   0.009  0.99312    
V5.l9  -1.959e-02  1.642e-02  -1.193  0.23305    
V6.l9   9.683e-02  3.642e-02   2.659  0.00798 ** 
V7.l9   2.957e-10  3.269e-09   0.090  0.92793    
V3.l10  2.671e-02  1.430e-02   1.867  0.06214 .  
V4.l10  4.090e-03  1.731e-02   0.236  0.81324    
V5.l10 -2.607e-02  1.629e-02  -1.601  0.10979    
V6.l10  9.962e-03  3.621e-02   0.275  0.78331    
V7.l10  4.051e-10  2.460e-09   0.165  0.86923    
const  -4.424e-03  1.449e-03  -3.054  0.00232 ** 
trend   5.016e-07  6.392e-07   0.785  0.43288    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


Residual standard error: 0.00385 on 937 degrees of freedom
Multiple R-Squared: 0.9995,	Adjusted R-squared: 0.9995 
F-statistic: 3.523e+04 on 51 and 937 DF,  p-value: < 2.2e-16 


Estimation results for equation V4: 
=================================== 
V4 = V3.l1 + V4.l1 + V5.l1 + V6.l1 + V7.l1 + V3.l2 + V4.l2 + V5.l2 + V6.l2 + V7.l2 + V3.l3 + V4.l3 + V5.l3 + V6.l3 + V7.l3 + V3.l4 + V4.l4 + V5.l4 + V6.l4 + V7.l4 + V3.l5 + V4.l5 + V5.l5 + V6.l5 + V7.l5 + V3.l6 + V4.l6 + V5.l6 + V6.l6 + V7.l6 + V3.l7 + V4.l7 + V5.l7 + V6.l7 + V7.l7 + V3.l8 + V4.l8 + V5.l8 + V6.l8 + V7.l8 + V3.l9 + V4.l9 + V5.l9 + V6.l9 + V7.l9 + V3.l10 + V4.l10 + V5.l10 + V6.l10 + V7.l10 + const + trend 

         Estimate Std. Error t value Pr(>|t|)    
V3.l1   8.893e-02  1.102e-01   0.807   0.4198    
V4.l1   7.385e-02  5.496e-02   1.344   0.1794    
V5.l1  -1.203e-01  5.035e-02  -2.390   0.0170 *  
V6.l1   9.804e-01  4.656e-02  21.056   <2e-16 ***
V7.l1   2.215e-09  7.611e-09   0.291   0.7711    
V3.l2  -1.110e-02  1.102e-01  -0.101   0.9198    
V4.l2   4.702e-02  5.579e-02   0.843   0.3996    
V5.l2  -3.964e-02  5.137e-02  -0.772   0.4405    
V6.l2  -7.074e-02  1.149e-01  -0.616   0.5384    
V7.l2  -3.774e-09  1.010e-08  -0.374   0.7086    
V3.l3  -1.826e-01  1.107e-01  -1.650   0.0993 .  
V4.l3   1.202e-01  5.586e-02   2.152   0.0316 *  
V5.l3   5.866e-02  5.193e-02   1.130   0.2589    
V6.l3  -2.245e-02  1.145e-01  -0.196   0.8446    
V7.l3   9.167e-09  1.008e-08   0.909   0.3634    
V3.l4   1.296e-01  1.103e-01   1.175   0.2404    
V4.l4  -1.065e-01  5.594e-02  -1.904   0.0573 .  
V5.l4  -5.299e-03  5.235e-02  -0.101   0.9194    
V6.l4   1.376e-01  1.150e-01   1.197   0.2318    
V7.l4   2.304e-10  1.012e-08   0.023   0.9818    
V3.l5   6.076e-02  1.105e-01   0.550   0.5826    
V4.l5   1.267e-01  5.603e-02   2.261   0.0240 *  
V5.l5  -1.201e-01  5.246e-02  -2.289   0.0223 *  
V6.l5  -1.057e-01  1.153e-01  -0.916   0.3597    
V7.l5  -1.476e-08  1.017e-08  -1.452   0.1469    
V3.l6  -4.499e-02  1.107e-01  -0.406   0.6845    
V4.l6   8.071e-03  5.625e-02   0.143   0.8859    
V5.l6  -1.419e-02  5.234e-02  -0.271   0.7864    
V6.l6  -1.836e-02  1.159e-01  -0.158   0.8742    
V7.l6  -5.189e-09  1.019e-08  -0.509   0.6106    
V3.l7  -3.695e-02  1.112e-01  -0.332   0.7398    
V4.l7  -1.799e-02  5.775e-02  -0.311   0.7555    
V5.l7   3.676e-02  5.284e-02   0.696   0.4869    
V6.l7   5.590e-02  1.155e-01   0.484   0.6286    
V7.l7   8.583e-09  1.032e-08   0.832   0.4058    
V3.l8  -5.701e-02  1.106e-01  -0.515   0.6064    
V4.l8   3.337e-02  5.779e-02   0.577   0.5638    
V5.l8  -8.257e-02  5.220e-02  -1.582   0.1141    
V6.l8  -1.854e-02  1.160e-01  -0.160   0.8731    
V7.l8   5.132e-10  1.033e-08   0.050   0.9604    
V3.l9   3.938e-02  1.107e-01   0.356   0.7220    
V4.l9   3.747e-02  5.702e-02   0.657   0.5112    
V5.l9  -2.008e-02  5.206e-02  -0.386   0.6998    
V6.l9   1.212e-01  1.155e-01   1.049   0.2944    
V7.l9  -3.628e-09  1.036e-08  -0.350   0.7264    
V3.l10  3.882e-02  4.535e-02   0.856   0.3922    
V4.l10  2.298e-02  5.488e-02   0.419   0.6756    
V5.l10 -7.085e-02  5.164e-02  -1.372   0.1704    
V6.l10 -5.189e-02  1.148e-01  -0.452   0.6515    
V7.l10  6.544e-09  7.799e-09   0.839   0.4017    
const   4.096e-03  4.593e-03   0.892   0.3727    
trend  -7.971e-08  2.027e-06  -0.039   0.9686    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


Residual standard error: 0.01221 on 937 degrees of freedom
Multiple R-Squared: 0.9948,	Adjusted R-squared: 0.9945 
F-statistic:  3493 on 51 and 937 DF,  p-value: < 2.2e-16 


Estimation results for equation V5: 
=================================== 
V5 = V3.l1 + V4.l1 + V5.l1 + V6.l1 + V7.l1 + V3.l2 + V4.l2 + V5.l2 + V6.l2 + V7.l2 + V3.l3 + V4.l3 + V5.l3 + V6.l3 + V7.l3 + V3.l4 + V4.l4 + V5.l4 + V6.l4 + V7.l4 + V3.l5 + V4.l5 + V5.l5 + V6.l5 + V7.l5 + V3.l6 + V4.l6 + V5.l6 + V6.l6 + V7.l6 + V3.l7 + V4.l7 + V5.l7 + V6.l7 + V7.l7 + V3.l8 + V4.l8 + V5.l8 + V6.l8 + V7.l8 + V3.l9 + V4.l9 + V5.l9 + V6.l9 + V7.l9 + V3.l10 + V4.l10 + V5.l10 + V6.l10 + V7.l10 + const + trend 

         Estimate Std. Error t value Pr(>|t|)    
V3.l1  -7.499e-02  1.272e-01  -0.590 0.555636    
V4.l1  -8.007e-02  6.346e-02  -1.262 0.207318    
V5.l1   1.849e-01  5.813e-02   3.181 0.001518 ** 
V6.l1   9.423e-01  5.376e-02  17.528  < 2e-16 ***
V7.l1  -3.280e-09  8.788e-09  -0.373 0.709082    
V3.l2   8.457e-02  1.272e-01   0.665 0.506420    
V4.l2  -1.338e-01  6.442e-02  -2.077 0.038030 *  
V5.l2   2.096e-01  5.931e-02   3.534 0.000429 ***
V6.l2  -3.433e-02  1.327e-01  -0.259 0.795899    
V7.l2   2.196e-09  1.166e-08   0.188 0.850627    
V3.l3  -2.865e-01  1.278e-01  -2.242 0.025206 *  
V4.l3  -3.530e-02  6.449e-02  -0.547 0.584232    
V5.l3   2.402e-01  5.995e-02   4.007 6.65e-05 ***
V6.l3  -1.725e-01  1.322e-01  -1.305 0.192218    
V7.l3   7.677e-09  1.164e-08   0.660 0.509700    
V3.l4   1.077e-01  1.274e-01   0.846 0.397930    
V4.l4  -1.462e-01  6.458e-02  -2.264 0.023795 *  
V5.l4  -1.739e-01  6.044e-02  -2.878 0.004096 ** 
V6.l4   2.954e-01  1.328e-01   2.225 0.026302 *  
V7.l4  -1.246e-08  1.168e-08  -1.066 0.286560    
V3.l5   2.131e-01  1.276e-01   1.670 0.095300 .  
V4.l5  -2.800e-02  6.469e-02  -0.433 0.665205    
V5.l5  -5.179e-02  6.057e-02  -0.855 0.392735    
V6.l5   4.773e-02  1.331e-01   0.358 0.720099    
V7.l5   9.485e-11  1.174e-08   0.008 0.993555    
V3.l6  -2.762e-01  1.278e-01  -2.161 0.030955 *  
V4.l6   2.070e-02  6.495e-02   0.319 0.750030    
V5.l6   7.136e-02  6.044e-02   1.181 0.238017    
V6.l6  -1.489e-01  1.339e-01  -1.113 0.266200    
V7.l6  -1.263e-11  1.176e-08  -0.001 0.999144    
V3.l7   8.459e-02  1.284e-01   0.659 0.510259    
V4.l7  -7.361e-02  6.668e-02  -1.104 0.269881    
V5.l7   5.939e-02  6.101e-02   0.973 0.330577    
V6.l7   2.549e-01  1.334e-01   1.911 0.056359 .  
V7.l7   5.319e-09  1.192e-08   0.446 0.655386    
V3.l8  -1.573e-01  1.277e-01  -1.232 0.218429    
V4.l8   7.412e-02  6.672e-02   1.111 0.266908    
V5.l8  -3.500e-02  6.027e-02  -0.581 0.561589    
V6.l8  -1.293e-01  1.339e-01  -0.966 0.334467    
V7.l8  -7.355e-09  1.193e-08  -0.617 0.537630    
V3.l9   2.760e-02  1.278e-01   0.216 0.828985    
V4.l9   6.122e-02  6.583e-02   0.930 0.352622    
V5.l9  -2.453e-02  6.011e-02  -0.408 0.683241    
V6.l9   1.342e-01  1.333e-01   1.006 0.314494    
V7.l9   5.821e-09  1.197e-08   0.486 0.626768    
V3.l10 -1.628e-02  5.236e-02  -0.311 0.755849    
V4.l10 -8.096e-02  6.337e-02  -1.278 0.201703    
V5.l10  7.221e-03  5.962e-02   0.121 0.903618    
V6.l10  3.439e-02  1.326e-01   0.259 0.795387    
V7.l10  8.116e-10  9.005e-09   0.090 0.928208    
const   5.373e-03  5.303e-03   1.013 0.311189    
trend  -1.758e-07  2.340e-06  -0.075 0.940128    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


Residual standard error: 0.01409 on 937 degrees of freedom
Multiple R-Squared: 0.993,	Adjusted R-squared: 0.9926 
F-statistic:  2600 on 51 and 937 DF,  p-value: < 2.2e-16 


Estimation results for equation V6: 
=================================== 
V6 = V3.l1 + V4.l1 + V5.l1 + V6.l1 + V7.l1 + V3.l2 + V4.l2 + V5.l2 + V6.l2 + V7.l2 + V3.l3 + V4.l3 + V5.l3 + V6.l3 + V7.l3 + V3.l4 + V4.l4 + V5.l4 + V6.l4 + V7.l4 + V3.l5 + V4.l5 + V5.l5 + V6.l5 + V7.l5 + V3.l6 + V4.l6 + V5.l6 + V6.l6 + V7.l6 + V3.l7 + V4.l7 + V5.l7 + V6.l7 + V7.l7 + V3.l8 + V4.l8 + V5.l8 + V6.l8 + V7.l8 + V3.l9 + V4.l9 + V5.l9 + V6.l9 + V7.l9 + V3.l10 + V4.l10 + V5.l10 + V6.l10 + V7.l10 + const + trend 

         Estimate Std. Error t value Pr(>|t|)    
V3.l1   1.003e-01  1.832e-01   0.547  0.58418    
V4.l1   2.105e-02  9.137e-02   0.230  0.81786    
V5.l1  -2.414e-04  8.371e-02  -0.003  0.99770    
V6.l1   9.950e-01  7.741e-02  12.853  < 2e-16 ***
V7.l1   2.109e-09  1.265e-08   0.167  0.86767    
V3.l2   1.494e-01  1.832e-01   0.815  0.41511    
V4.l2  -1.232e-01  9.276e-02  -1.329  0.18433    
V5.l2   1.898e-01  8.541e-02   2.222  0.02650 *  
V6.l2  -2.334e-01  1.911e-01  -1.222  0.22218    
V7.l2  -3.473e-09  1.678e-08  -0.207  0.83612    
V3.l3  -4.602e-01  1.840e-01  -2.501  0.01255 *  
V4.l3   3.126e-02  9.287e-02   0.337  0.73648    
V5.l3   2.181e-01  8.633e-02   2.526  0.01169 *  
V6.l3  -1.945e-01  1.903e-01  -1.022  0.30700    
V7.l3   1.025e-08  1.676e-08   0.612  0.54082    
V3.l4   1.643e-01  1.834e-01   0.896  0.37052    
V4.l4  -2.561e-01  9.300e-02  -2.754  0.00601 ** 
V5.l4  -1.499e-01  8.703e-02  -1.722  0.08534 .  
V6.l4   5.116e-01  1.912e-01   2.676  0.00758 ** 
V7.l4  -9.885e-09  1.682e-08  -0.588  0.55690    
V3.l5   7.083e-02  1.837e-01   0.386  0.69993    
V4.l5   8.401e-02  9.315e-02   0.902  0.36735    
V5.l5  -1.521e-01  8.721e-02  -1.743  0.08159 .  
V6.l5   1.482e-02  1.917e-01   0.077  0.93840    
V7.l5  -1.063e-08  1.690e-08  -0.629  0.52958    
V3.l6  -2.494e-01  1.840e-01  -1.355  0.17565    
V4.l6   4.918e-02  9.353e-02   0.526  0.59910    
V5.l6   5.305e-02  8.702e-02   0.610  0.54229    
V6.l6  -2.493e-02  1.928e-01  -0.129  0.89712    
V7.l6  -4.569e-09  1.694e-08  -0.270  0.78741    
V3.l7   1.223e-01  1.849e-01   0.661  0.50855    
V4.l7   2.154e-02  9.601e-02   0.224  0.82250    
V5.l7   5.986e-02  8.786e-02   0.681  0.49586    
V6.l7   1.890e-01  1.921e-01   0.984  0.32528    
V7.l7   5.562e-09  1.716e-08   0.324  0.74585    
V3.l8  -1.093e-01  1.839e-01  -0.595  0.55225    
V4.l8  -1.184e-02  9.608e-02  -0.123  0.90196    
V5.l8  -8.629e-02  8.679e-02  -0.994  0.32038    
V6.l8  -1.994e-01  1.929e-01  -1.034  0.30155    
V7.l8   7.015e-09  1.717e-08   0.408  0.68304    
V3.l9  -3.546e-02  1.840e-01  -0.193  0.84719    
V4.l9   1.151e-01  9.479e-02   1.215  0.22477    
V5.l9   3.148e-02  8.655e-02   0.364  0.71615    
V6.l9   1.233e-01  1.920e-01   0.642  0.52090    
V7.l9   2.161e-09  1.723e-08   0.125  0.90022    
V3.l10 -3.399e-02  7.539e-02  -0.451  0.65218    
V4.l10  6.509e-03  9.124e-02   0.071  0.94314    
V5.l10 -5.308e-02  8.585e-02  -0.618  0.53651    
V6.l10  4.494e-02  1.909e-01   0.235  0.81395    
V7.l10 -3.758e-09  1.297e-08  -0.290  0.77204    
const   1.383e-02  7.636e-03   1.811  0.07043 .  
trend   5.040e-07  3.370e-06   0.150  0.88115    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


Residual standard error: 0.02029 on 937 degrees of freedom
Multiple R-Squared: 0.9855,	Adjusted R-squared: 0.9847 
F-statistic:  1251 on 51 and 937 DF,  p-value: < 2.2e-16 


Estimation results for equation V7: 
=================================== 
V7 = V3.l1 + V4.l1 + V5.l1 + V6.l1 + V7.l1 + V3.l2 + V4.l2 + V5.l2 + V6.l2 + V7.l2 + V3.l3 + V4.l3 + V5.l3 + V6.l3 + V7.l3 + V3.l4 + V4.l4 + V5.l4 + V6.l4 + V7.l4 + V3.l5 + V4.l5 + V5.l5 + V6.l5 + V7.l5 + V3.l6 + V4.l6 + V5.l6 + V6.l6 + V7.l6 + V3.l7 + V4.l7 + V5.l7 + V6.l7 + V7.l7 + V3.l8 + V4.l8 + V5.l8 + V6.l8 + V7.l8 + V3.l9 + V4.l9 + V5.l9 + V6.l9 + V7.l9 + V3.l10 + V4.l10 + V5.l10 + V6.l10 + V7.l10 + const + trend 

         Estimate Std. Error t value Pr(>|t|)    
V3.l1   7.716e+05  4.718e+05   1.635  0.10233    
V4.l1  -1.081e+05  2.354e+05  -0.459  0.64627    
V5.l1  -6.181e+04  2.156e+05  -0.287  0.77447    
V6.l1   5.567e+04  1.994e+05   0.279  0.78019    
V7.l1   8.553e-01  3.260e-02  26.237  < 2e-16 ***
V3.l2  -7.817e+05  4.720e+05  -1.656  0.09801 .  
V4.l2  -3.345e+04  2.390e+05  -0.140  0.88870    
V5.l2   1.447e+05  2.200e+05   0.658  0.51097    
V6.l2  -8.731e+05  4.922e+05  -1.774  0.07641 .  
V7.l2   7.572e-03  4.324e-02   0.175  0.86101    
V3.l3   4.075e+05  4.740e+05   0.860  0.39018    
V4.l3   6.469e+04  2.392e+05   0.270  0.78691    
V5.l3   2.367e+04  2.224e+05   0.106  0.91528    
V6.l3   8.217e+05  4.903e+05   1.676  0.09410 .  
V7.l3   7.772e-02  4.318e-02   1.800  0.07217 .  
V3.l4  -3.742e+05  4.725e+05  -0.792  0.42859    
V4.l4   9.746e+03  2.396e+05   0.041  0.96756    
V5.l4  -7.457e+04  2.242e+05  -0.333  0.73950    
V6.l4  -4.846e+05  4.925e+05  -0.984  0.32537    
V7.l4  -6.512e-02  4.333e-02  -1.503  0.13319    
V3.l5  -1.097e+05  4.733e+05  -0.232  0.81679    
V4.l5  -8.191e+03  2.400e+05  -0.034  0.97278    
V5.l5   1.029e+04  2.247e+05   0.046  0.96350    
V6.l5   3.926e+05  4.939e+05   0.795  0.42685    
V7.l5  -2.886e-02  4.354e-02  -0.663  0.50767    
V3.l6   2.079e+05  4.741e+05   0.439  0.66110    
V4.l6  -3.581e+05  2.409e+05  -1.486  0.13752    
V5.l6   1.481e+05  2.242e+05   0.661  0.50896    
V6.l6   2.031e+05  4.966e+05   0.409  0.68262    
V7.l6   8.119e-02  4.363e-02   1.861  0.06308 .  
V3.l7   3.814e+04  4.764e+05   0.080  0.93620    
V4.l7   3.997e+05  2.473e+05   1.616  0.10644    
V5.l7  -2.280e+04  2.263e+05  -0.101  0.91978    
V6.l7  -1.949e+05  4.948e+05  -0.394  0.69381    
V7.l7  -1.734e-02  4.420e-02  -0.392  0.69485    
V3.l8   1.724e+04  4.737e+05   0.036  0.97098    
V4.l8  -5.745e+04  2.475e+05  -0.232  0.81650    
V5.l8   7.599e+04  2.236e+05   0.340  0.73404    
V6.l8  -2.405e+05  4.969e+05  -0.484  0.62848    
V7.l8  -1.071e-01  4.424e-02  -2.420  0.01569 *  
V3.l9   3.979e+05  4.739e+05   0.840  0.40134    
V4.l9   1.173e+05  2.442e+05   0.480  0.63108    
V5.l9   1.859e+05  2.230e+05   0.834  0.40462    
V6.l9  -1.805e+05  4.946e+05  -0.365  0.71521    
V7.l9  -7.430e-02  4.439e-02  -1.674  0.09451 .  
V3.l10 -1.265e+05  1.942e+05  -0.652  0.51486    
V4.l10  3.112e+04  2.351e+05   0.132  0.89469    
V5.l10  3.205e+05  2.211e+05   1.449  0.14757    
V6.l10 -7.664e+05  4.918e+05  -1.558  0.11948    
V7.l10  2.249e-01  3.340e-02   6.733 2.89e-11 ***
const   2.655e+04  1.967e+04   1.350  0.17745    
trend   2.326e+01  8.681e+00   2.679  0.00751 ** 
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


Residual standard error: 52280 on 937 degrees of freedom
Multiple R-Squared: 0.936,	Adjusted R-squared: 0.9325 
F-statistic: 268.6 on 51 and 937 DF,  p-value: < 2.2e-16 



Covariance matrix of residuals:
           V3        V4         V5         V6         V7
V3  1.482e-05 9.228e-06  7.926e-06  3.905e-06 -1.093e+01
V4  9.228e-06 1.490e-04  9.214e-05  1.898e-04  4.843e+01
V5  7.926e-06 9.214e-05  1.986e-04  2.306e-04 -7.977e+01
V6  3.905e-06 1.898e-04  2.306e-04  4.119e-04 -3.903e+01
V7 -1.093e+01 4.843e+01 -7.977e+01 -3.903e+01  2.733e+09

Correlation matrix of residuals:
         V3      V4      V5       V6       V7
V3  1.00000 0.19637  0.1461  0.04999 -0.05433
V4  0.19637 1.00000  0.5356  0.76621  0.07588
V5  0.14608 0.53558  1.0000  0.80621 -0.10827
V6  0.04999 0.76621  0.8062  1.00000 -0.03678
V7 -0.05433 0.07588 -0.1083 -0.03678  1.00000


> 
> fitvar1 = VAR(lr, p=10, type="both")
> 
> # auto correlation function for residuals for close price
> 
> acf(residuals(fitvar1)[,4])
> 
> # auto correlation function for residuals for open, high and low price
> 
> acf(residuals(fitvar1)[,1])
> 
> acf(residuals(fitvar1)[,2])
> 
> acf(residuals(fitvar1)[,3])
> 
> #vector auto regression of Open, High, Low and Close
> 
> #predict the next 10 values
> 
> var.pred <- predict(fitvar1, n.ahead=3, ci=0.95)
> 
> var.pred
$V3
         fcst    lower    upper          CI
[1,] 1.309286 1.301741 1.316832 0.007545514
[2,] 1.310732 1.270236 1.351228 0.040496033
[3,] 1.312006 1.255404 1.368609 0.056602615

$V4
         fcst    lower    upper         CI
[1,] 1.320224 1.296299 1.344149 0.02392477
[2,] 1.338595 1.293872 1.383318 0.04472325
[3,] 1.333909 1.275277 1.392541 0.05863241

$V5
         fcst    lower    upper         CI
[1,] 1.287867 1.260244 1.315490 0.02762322
[2,] 1.290540 1.241703 1.339377 0.04883692
[3,] 1.303158 1.239837 1.366480 0.06332178

$V6
         fcst    lower    upper         CI
[1,] 1.310808 1.271032 1.350584 0.03977584
[2,] 1.310701 1.254293 1.367109 0.05640817
[3,] 1.325592 1.257826 1.393357 0.06776577

$V7
         fcst    lower    upper       CI
[1,] 538530.5 436063.6 640997.4 102466.9
[2,] 467243.1 332563.5 601922.7 134679.6
[3,] 434972.6 280427.9 589517.3 154544.7

> 
> quotes[(x-1):x,]
             V1    V2      V3      V4      V5      V6     V7
1025 2016.08.07 00:00 1.30809 1.30969 1.29084 1.29100 355199
1026 2016.08.14 00:00 1.29274 1.29400 1.29007 1.29318   6854

You can see the predicted Open, High, Low and Close for next week is 1.30928, 1.320224, 1.28786 and 1.31080 while the actual Open, High, Low and Close was 1.30809, 1.30969, 1.29084 and 1.29100. So you can see this model did not make a good prediction of the weekly candle.

Daily Candle Prediction Using VAR Model

Now we run this model for the daily candle and see how good prediction we get for the daily candle.

> # Import the csv file
> quotes <- read.csv("E:/MarketData/GBPUSD1440.csv", header=FALSE)
> 
> 
> x <-nrow(quotes)
> 
> lr <- quotes[(x-1000):(x-5),3:7]
> 
> 
> #install vars package
> 
> library(vars)
> 
> summary(VAR(lr, p=10, type="both"))

VAR Estimation Results:
========================= 
Endogenous variables: V3, V4, V5, V6, V7 
Deterministic variables: both 
Sample size: 986 
Log Likelihood: 5634.754 
Roots of the characteristic polynomial:
0.9936 0.9662 0.8731 0.8731 0.8717 0.8717 0.8629 0.8498 0.8498 0.8237 0.8237 0.8191 0.8169 0.8169 0.8147 0.8147 0.8112 0.8112 0.7894 0.7894 0.7882 0.7882 0.7756 0.7756 0.757 0.757 0.7566 0.7522 0.7522 0.7465 0.7465 0.7376 0.7376 0.7369 0.7369 0.7111 0.7111 0.7051 0.6933 0.6933 0.6797 0.6797 0.6461 0.6305 0.6284 0.6284 0.4777 0.4777 0.2771 0.2771
Call:
VAR(y = lr, p = 10, type = "both")


Estimation results for equation V3: 
=================================== 
V3 = V3.l1 + V4.l1 + V5.l1 + V6.l1 + V7.l1 + V3.l2 + V4.l2 + V5.l2 + V6.l2 + V7.l2 + V3.l3 + V4.l3 + V5.l3 + V6.l3 + V7.l3 + V3.l4 + V4.l4 + V5.l4 + V6.l4 + V7.l4 + V3.l5 + V4.l5 + V5.l5 + V6.l5 + V7.l5 + V3.l6 + V4.l6 + V5.l6 + V6.l6 + V7.l6 + V3.l7 + V4.l7 + V5.l7 + V6.l7 + V7.l7 + V3.l8 + V4.l8 + V5.l8 + V6.l8 + V7.l8 + V3.l9 + V4.l9 + V5.l9 + V6.l9 + V7.l9 + V3.l10 + V4.l10 + V5.l10 + V6.l10 + V7.l10 + const + trend 

         Estimate Std. Error t value Pr(>|t|)    
V3.l1  -9.319e-02  3.536e-02  -2.635  0.00855 ** 
V4.l1  -2.637e-02  1.576e-02  -1.673  0.09460 .  
V5.l1   1.094e-01  1.420e-02   7.706 3.32e-14 ***
V6.l1   9.860e-01  1.511e-02  65.272  < 2e-16 ***
V7.l1   1.855e-09  1.477e-09   1.256  0.20950    
V3.l2  -3.533e-02  3.557e-02  -0.993  0.32082    
V4.l2   6.974e-03  1.588e-02   0.439  0.66071    
V5.l2  -1.143e-02  1.460e-02  -0.783  0.43411    
V6.l2   3.161e-02  3.565e-02   0.887  0.37542    
V7.l2  -3.795e-10  1.571e-09  -0.242  0.80918    
V3.l3  -2.396e-02  3.560e-02  -0.673  0.50116    
V4.l3   4.055e-03  1.581e-02   0.257  0.79758    
V5.l3   8.547e-03  1.457e-02   0.587  0.55759    
V6.l3   3.223e-02  3.557e-02   0.906  0.36504    
V7.l3   5.576e-10  1.583e-09   0.352  0.72475    
V3.l4   3.055e-02  3.559e-02   0.858  0.39090    
V4.l4  -4.362e-02  1.588e-02  -2.748  0.00612 ** 
V5.l4  -3.874e-02  1.459e-02  -2.655  0.00807 ** 
V6.l4   6.579e-02  3.567e-02   1.844  0.06543 .  
V7.l4  -1.230e-09  1.591e-09  -0.773  0.43978    
V3.l5  -9.809e-02  3.615e-02  -2.713  0.00678 ** 
V4.l5   1.357e-02  1.595e-02   0.851  0.39493    
V5.l5  -7.406e-03  1.470e-02  -0.504  0.61457    
V6.l5  -4.511e-03  3.561e-02  -0.127  0.89924    
V7.l5   5.364e-11  1.586e-09   0.034  0.97303    
V3.l6  -4.473e-03  3.633e-02  -0.123  0.90206    
V4.l6  -1.902e-03  1.590e-02  -0.120  0.90482    
V5.l6   1.518e-02  1.473e-02   1.030  0.30311    
V6.l6   8.784e-02  3.612e-02   2.432  0.01521 *  
V7.l6   3.086e-10  1.585e-09   0.195  0.84571    
V3.l7  -6.115e-02  3.609e-02  -1.694  0.09053 .  
V4.l7   4.979e-02  1.591e-02   3.129  0.00181 ** 
V5.l7   3.044e-02  1.474e-02   2.065  0.03917 *  
V6.l7  -4.487e-02  3.624e-02  -1.238  0.21591    
V7.l7   2.041e-11  1.585e-09   0.013  0.98973    
V3.l8   2.435e-02  3.634e-02   0.670  0.50298    
V4.l8  -1.709e-02  1.591e-02  -1.074  0.28296    
V5.l8  -1.685e-02  1.474e-02  -1.143  0.25343    
V6.l8   3.794e-02  3.611e-02   1.051  0.29368    
V7.l8  -1.661e-09  1.577e-09  -1.053  0.29240    
V3.l9  -6.258e-02  3.629e-02  -1.725  0.08491 .  
V4.l9   3.590e-02  1.593e-02   2.253  0.02446 *  
V5.l9   8.078e-03  1.479e-02   0.546  0.58501    
V6.l9  -1.806e-02  3.643e-02  -0.496  0.62010    
V7.l9   1.041e-09  1.563e-09   0.666  0.50556    
V3.l10 -1.596e-02  1.388e-02  -1.150  0.25046    
V4.l10  4.676e-03  1.597e-02   0.293  0.76982    
V5.l10  9.758e-03  1.478e-02   0.660  0.50929    
V6.l10  3.242e-02  3.631e-02   0.893  0.37206    
V7.l10  1.579e-09  1.466e-09   1.076  0.28199    
const   1.038e-03  1.400e-03   0.741  0.45873    
trend  -1.283e-07  2.258e-07  -0.568  0.57002    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


Residual standard error: 0.001302 on 934 degrees of freedom
Multiple R-Squared: 0.9998,	Adjusted R-squared: 0.9998 
F-statistic: 8.245e+04 on 51 and 934 DF,  p-value: < 2.2e-16 


Estimation results for equation V4: 
=================================== 
V4 = V3.l1 + V4.l1 + V5.l1 + V6.l1 + V7.l1 + V3.l2 + V4.l2 + V5.l2 + V6.l2 + V7.l2 + V3.l3 + V4.l3 + V5.l3 + V6.l3 + V7.l3 + V3.l4 + V4.l4 + V5.l4 + V6.l4 + V7.l4 + V3.l5 + V4.l5 + V5.l5 + V6.l5 + V7.l5 + V3.l6 + V4.l6 + V5.l6 + V6.l6 + V7.l6 + V3.l7 + V4.l7 + V5.l7 + V6.l7 + V7.l7 + V3.l8 + V4.l8 + V5.l8 + V6.l8 + V7.l8 + V3.l9 + V4.l9 + V5.l9 + V6.l9 + V7.l9 + V3.l10 + V4.l10 + V5.l10 + V6.l10 + V7.l10 + const + trend 

         Estimate Std. Error t value Pr(>|t|)    
V3.l1  -2.137e-02  1.355e-01  -0.158   0.8747    
V4.l1  -9.351e-02  6.037e-02  -1.549   0.1218    
V5.l1   6.453e-02  5.439e-02   1.186   0.2358    
V6.l1   1.042e+00  5.787e-02  18.007  < 2e-16 ***
V7.l1   8.568e-09  5.660e-09   1.514   0.1305    
V3.l2   9.777e-02  1.363e-01   0.718   0.4732    
V4.l2   4.072e-02  6.085e-02   0.669   0.5035    
V5.l2  -6.018e-02  5.594e-02  -1.076   0.2823    
V6.l2   2.610e-02  1.366e-01   0.191   0.8485    
V7.l2   6.496e-09  6.020e-09   1.079   0.2808    
V3.l3   2.076e-01  1.364e-01   1.522   0.1284    
V4.l3  -6.666e-02  6.055e-02  -1.101   0.2713    
V5.l3  -9.251e-02  5.582e-02  -1.657   0.0978 .  
V6.l3  -5.625e-02  1.363e-01  -0.413   0.6798    
V7.l3  -6.398e-09  6.065e-09  -1.055   0.2917    
V3.l4   3.484e-01  1.364e-01   2.555   0.0108 *  
V4.l4  -1.202e-01  6.083e-02  -1.976   0.0485 *  
V5.l4  -1.007e-01  5.590e-02  -1.802   0.0719 .  
V6.l4   1.772e-02  1.367e-01   0.130   0.8969    
V7.l4  -4.718e-10  6.096e-09  -0.077   0.9383    
V3.l5   3.264e-02  1.385e-01   0.236   0.8137    
V4.l5   8.265e-03  6.110e-02   0.135   0.8924    
V5.l5  -5.888e-02  5.632e-02  -1.045   0.2961    
V6.l5  -2.329e-01  1.364e-01  -1.707   0.0882 .  
V7.l5  -2.278e-09  6.076e-09  -0.375   0.7078    
V3.l6   4.075e-03  1.392e-01   0.029   0.9767    
V4.l6  -1.283e-02  6.093e-02  -0.211   0.8332    
V5.l6  -5.057e-02  5.642e-02  -0.896   0.3703    
V6.l6   5.970e-02  1.384e-01   0.431   0.6663    
V7.l6  -8.713e-10  6.074e-09  -0.143   0.8860    
V3.l7  -2.582e-02  1.383e-01  -0.187   0.8519    
V4.l7   4.276e-02  6.097e-02   0.701   0.4832    
V5.l7   9.950e-02  5.647e-02   1.762   0.0784 .  
V6.l7  -8.214e-02  1.388e-01  -0.592   0.5542    
V7.l7   1.060e-09  6.073e-09   0.175   0.8615    
V3.l8  -4.635e-02  1.392e-01  -0.333   0.7392    
V4.l8   1.038e-02  6.094e-02   0.170   0.8647    
V5.l8   4.205e-02  5.648e-02   0.745   0.4567    
V6.l8  -8.289e-02  1.383e-01  -0.599   0.5492    
V7.l8   4.292e-09  6.041e-09   0.710   0.4776    
V3.l9   4.436e-02  1.390e-01   0.319   0.7497    
V4.l9  -3.187e-02  6.103e-02  -0.522   0.6017    
V5.l9  -4.553e-02  5.665e-02  -0.804   0.4217    
V6.l9   7.967e-02  1.396e-01   0.571   0.5682    
V7.l9  -7.693e-11  5.987e-09  -0.013   0.9898    
V3.l10 -2.719e-03  5.317e-02  -0.051   0.9592    
V4.l10  1.819e-02  6.120e-02   0.297   0.7663    
V5.l10 -1.833e-02  5.663e-02  -0.324   0.7462    
V6.l10  3.164e-04  1.391e-01   0.002   0.9982    
V7.l10 -2.223e-09  5.618e-09  -0.396   0.6924    
const   2.908e-02  5.364e-03   5.422  7.5e-08 ***
trend  -9.603e-07  8.652e-07  -1.110   0.2674    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


Residual standard error: 0.004989 on 934 degrees of freedom
Multiple R-Squared: 0.9966,	Adjusted R-squared: 0.9965 
F-statistic:  5431 on 51 and 934 DF,  p-value: < 2.2e-16 


Estimation results for equation V5: 
=================================== 
V5 = V3.l1 + V4.l1 + V5.l1 + V6.l1 + V7.l1 + V3.l2 + V4.l2 + V5.l2 + V6.l2 + V7.l2 + V3.l3 + V4.l3 + V5.l3 + V6.l3 + V7.l3 + V3.l4 + V4.l4 + V5.l4 + V6.l4 + V7.l4 + V3.l5 + V4.l5 + V5.l5 + V6.l5 + V7.l5 + V3.l6 + V4.l6 + V5.l6 + V6.l6 + V7.l6 + V3.l7 + V4.l7 + V5.l7 + V6.l7 + V7.l7 + V3.l8 + V4.l8 + V5.l8 + V6.l8 + V7.l8 + V3.l9 + V4.l9 + V5.l9 + V6.l9 + V7.l9 + V3.l10 + V4.l10 + V5.l10 + V6.l10 + V7.l10 + const + trend 

         Estimate Std. Error t value Pr(>|t|)    
V3.l1  -1.829e-02  1.848e-01  -0.099 0.921159    
V4.l1  -3.141e-01  8.235e-02  -3.814 0.000146 ***
V5.l1   7.342e-02  7.419e-02   0.990 0.322618    
V6.l1   1.108e+00  7.893e-02  14.041  < 2e-16 ***
V7.l1  -1.244e-08  7.720e-09  -1.611 0.107462    
V3.l2   1.848e-01  1.858e-01   0.995 0.320178    
V4.l2  -8.525e-02  8.300e-02  -1.027 0.304609    
V5.l2  -1.704e-01  7.630e-02  -2.234 0.025733 *  
V6.l2   3.169e-01  1.863e-01   1.701 0.089231 .  
V7.l2   6.312e-09  8.210e-09   0.769 0.442200    
V3.l3  -6.741e-02  1.860e-01  -0.362 0.717163    
V4.l3  -7.400e-02  8.259e-02  -0.896 0.370533    
V5.l3  -8.990e-02  7.613e-02  -1.181 0.237969    
V6.l3  -2.240e-02  1.858e-01  -0.121 0.904100    
V7.l3  -1.540e-11  8.272e-09  -0.002 0.998515    
V3.l4  -7.687e-01  1.860e-01  -4.133 3.90e-05 ***
V4.l4  -1.738e-01  8.296e-02  -2.095 0.036407 *  
V5.l4   1.159e-01  7.625e-02   1.521 0.128693    
V6.l4   1.470e-01  1.864e-01   0.789 0.430351    
V7.l4  -2.929e-09  8.315e-09  -0.352 0.724718    
V3.l5  -1.853e-01  1.889e-01  -0.981 0.326722    
V4.l5  -9.323e-02  8.333e-02  -1.119 0.263548    
V5.l5   8.284e-02  7.682e-02   1.078 0.281116    
V6.l5   8.068e-01  1.861e-01   4.335 1.61e-05 ***
V7.l5   5.350e-09  8.288e-09   0.646 0.518699    
V3.l6  -6.964e-02  1.899e-01  -0.367 0.713830    
V4.l6   1.697e-01  8.310e-02   2.042 0.041456 *  
V5.l6   2.516e-01  7.696e-02   3.270 0.001117 ** 
V6.l6  -6.916e-04  1.887e-01  -0.004 0.997077    
V7.l6   2.371e-09  8.284e-09   0.286 0.774752    
V3.l7  -9.441e-02  1.886e-01  -0.501 0.616740    
V4.l7   5.609e-02  8.315e-02   0.675 0.500160    
V5.l7   1.198e-01  7.703e-02   1.556 0.120161    
V6.l7  -1.815e-01  1.893e-01  -0.958 0.338059    
V7.l7   7.488e-09  8.284e-09   0.904 0.366239    
V3.l8  -4.161e-02  1.899e-01  -0.219 0.826589    
V4.l8   2.061e-02  8.312e-02   0.248 0.804253    
V5.l8   2.639e-03  7.704e-02   0.034 0.972678    
V6.l8   1.763e-02  1.887e-01   0.093 0.925598    
V7.l8  -3.987e-09  8.240e-09  -0.484 0.628572    
V3.l9  -4.596e-02  1.896e-01  -0.242 0.808522    
V4.l9   1.326e-01  8.325e-02   1.593 0.111572    
V5.l9   1.477e-01  7.727e-02   1.912 0.056184 .  
V6.l9  -2.284e-01  1.903e-01  -1.200 0.230370    
V7.l9   1.755e-09  8.166e-09   0.215 0.829873    
V3.l10 -1.327e-01  7.252e-02  -1.830 0.067562 .  
V4.l10  7.385e-02  8.347e-02   0.885 0.376505    
V5.l10  6.001e-02  7.723e-02   0.777 0.437346    
V6.l10 -3.097e-02  1.897e-01  -0.163 0.870372    
V7.l10  9.871e-10  7.662e-09   0.129 0.897529    
const   2.898e-04  7.316e-03   0.040 0.968414    
trend  -1.780e-06  1.180e-06  -1.509 0.131738    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


Residual standard error: 0.006805 on 934 degrees of freedom
Multiple R-Squared: 0.9941,	Adjusted R-squared: 0.9938 
F-statistic:  3111 on 51 and 934 DF,  p-value: < 2.2e-16 


Estimation results for equation V6: 
=================================== 
V6 = V3.l1 + V4.l1 + V5.l1 + V6.l1 + V7.l1 + V3.l2 + V4.l2 + V5.l2 + V6.l2 + V7.l2 + V3.l3 + V4.l3 + V5.l3 + V6.l3 + V7.l3 + V3.l4 + V4.l4 + V5.l4 + V6.l4 + V7.l4 + V3.l5 + V4.l5 + V5.l5 + V6.l5 + V7.l5 + V3.l6 + V4.l6 + V5.l6 + V6.l6 + V7.l6 + V3.l7 + V4.l7 + V5.l7 + V6.l7 + V7.l7 + V3.l8 + V4.l8 + V5.l8 + V6.l8 + V7.l8 + V3.l9 + V4.l9 + V5.l9 + V6.l9 + V7.l9 + V3.l10 + V4.l10 + V5.l10 + V6.l10 + V7.l10 + const + trend 

         Estimate Std. Error t value Pr(>|t|)    
V3.l1   3.367e-01  2.253e-01   1.494 0.135387    
V4.l1  -3.881e-01  1.004e-01  -3.866 0.000118 ***
V5.l1  -2.200e-02  9.044e-02  -0.243 0.807873    
V6.l1   1.179e+00  9.623e-02  12.255  < 2e-16 ***
V7.l1  -2.882e-09  9.412e-09  -0.306 0.759468    
V3.l2   2.041e-01  2.266e-01   0.901 0.367788    
V4.l2  -7.237e-02  1.012e-01  -0.715 0.474661    
V5.l2  -2.325e-01  9.301e-02  -2.500 0.012591 *  
V6.l2   7.984e-02  2.271e-01   0.352 0.725235    
V7.l2   7.645e-09  1.001e-08   0.764 0.445163    
V3.l3   2.409e-01  2.268e-01   1.062 0.288462    
V4.l3  -1.585e-01  1.007e-01  -1.574 0.115798    
V5.l3  -1.465e-01  9.281e-02  -1.578 0.114903    
V6.l3   2.439e-02  2.266e-01   0.108 0.914284    
V7.l3   3.626e-09  1.008e-08   0.360 0.719269    
V3.l4  -3.998e-01  2.267e-01  -1.763 0.078145 .  
V4.l4  -1.811e-01  1.011e-01  -1.790 0.073703 .  
V5.l4  -1.719e-03  9.295e-02  -0.018 0.985251    
V6.l4   2.633e-03  2.272e-01   0.012 0.990758    
V7.l4  -3.595e-09  1.014e-08  -0.355 0.722889    
V3.l5  -1.582e-01  2.303e-01  -0.687 0.492234    
V4.l5  -9.912e-02  1.016e-01  -0.976 0.329491    
V5.l5   6.789e-02  9.365e-02   0.725 0.468687    
V6.l5   4.993e-01  2.269e-01   2.201 0.027989 *  
V7.l5   3.021e-09  1.010e-08   0.299 0.765016    
V3.l6  -1.322e-02  2.314e-01  -0.057 0.954458    
V4.l6   1.370e-01  1.013e-01   1.353 0.176508    
V5.l6   1.814e-01  9.382e-02   1.934 0.053474 .  
V6.l6   6.317e-02  2.301e-01   0.275 0.783727    
V7.l6   2.521e-09  1.010e-08   0.250 0.802954    
V3.l7   4.250e-02  2.299e-01   0.185 0.853386    
V4.l7   4.719e-02  1.014e-01   0.465 0.641693    
V5.l7   1.682e-01  9.390e-02   1.791 0.073546 .  
V6.l7  -2.684e-01  2.308e-01  -1.163 0.245204    
V7.l7   2.276e-09  1.010e-08   0.225 0.821770    
V3.l8   9.332e-04  2.315e-01   0.004 0.996784    
V4.l8   1.361e-02  1.013e-01   0.134 0.893166    
V5.l8  -6.082e-02  9.392e-02  -0.648 0.517421    
V6.l8  -1.062e-01  2.300e-01  -0.462 0.644388    
V7.l8  -4.049e-09  1.005e-08  -0.403 0.686981    
V3.l9   1.532e-01  2.311e-01   0.663 0.507662    
V4.l9   2.968e-02  1.015e-01   0.292 0.770000    
V5.l9   7.221e-02  9.420e-02   0.767 0.443524    
V6.l9  -8.450e-02  2.320e-01  -0.364 0.715843    
V7.l9   4.529e-09  9.955e-09   0.455 0.649265    
V3.l10 -1.155e-03  8.841e-02  -0.013 0.989576    
V4.l10 -2.097e-02  1.018e-01  -0.206 0.836787    
V5.l10 -2.282e-02  9.416e-02  -0.242 0.808558    
V6.l10 -1.200e-01  2.313e-01  -0.519 0.603910    
V7.l10  3.200e-10  9.341e-09   0.034 0.972677    
const   2.554e-02  8.919e-03   2.863 0.004289 ** 
trend  -3.021e-06  1.439e-06  -2.100 0.035987 *  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


Residual standard error: 0.008295 on 934 degrees of freedom
Multiple R-Squared: 0.991,	Adjusted R-squared: 0.9905 
F-statistic:  2024 on 51 and 934 DF,  p-value: < 2.2e-16 


Estimation results for equation V7: 
=================================== 
V7 = V3.l1 + V4.l1 + V5.l1 + V6.l1 + V7.l1 + V3.l2 + V4.l2 + V5.l2 + V6.l2 + V7.l2 + V3.l3 + V4.l3 + V5.l3 + V6.l3 + V7.l3 + V3.l4 + V4.l4 + V5.l4 + V6.l4 + V7.l4 + V3.l5 + V4.l5 + V5.l5 + V6.l5 + V7.l5 + V3.l6 + V4.l6 + V5.l6 + V6.l6 + V7.l6 + V3.l7 + V4.l7 + V5.l7 + V6.l7 + V7.l7 + V3.l8 + V4.l8 + V5.l8 + V6.l8 + V7.l8 + V3.l9 + V4.l9 + V5.l9 + V6.l9 + V7.l9 + V3.l10 + V4.l10 + V5.l10 + V6.l10 + V7.l10 + const + trend 

         Estimate Std. Error t value Pr(>|t|)    
V3.l1  -9.316e+05  8.352e+05  -1.116   0.2649    
V4.l1  -1.262e+05  3.722e+05  -0.339   0.7345    
V5.l1  -1.918e+05  3.353e+05  -0.572   0.5674    
V6.l1   4.801e+05  3.567e+05   1.346   0.1787    
V7.l1   3.832e-01  3.489e-02  10.981  < 2e-16 ***
V3.l2  -1.699e+06  8.400e+05  -2.023   0.0433 *  
V4.l2   1.251e+05  3.751e+05   0.334   0.7388    
V5.l2   2.759e+05  3.448e+05   0.800   0.4239    
V6.l2   7.475e+05  8.419e+05   0.888   0.3748    
V7.l2   1.455e-01  3.711e-02   3.922 9.44e-05 ***
V3.l3   1.653e+06  8.408e+05   1.965   0.0497 *  
V4.l3  -9.239e+05  3.733e+05  -2.475   0.0135 *  
V5.l3   2.028e+05  3.441e+05   0.589   0.5558    
V6.l3   1.570e+06  8.399e+05   1.869   0.0619 .  
V7.l3   5.747e-02  3.739e-02   1.537   0.1246    
V3.l4   1.445e+06  8.406e+05   1.719   0.0860 .  
V4.l4   7.055e+05  3.750e+05   1.882   0.0602 .  
V5.l4  -5.551e+05  3.446e+05  -1.611   0.1076    
V6.l4  -1.127e+06  8.424e+05  -1.338   0.1813    
V7.l4  -1.332e-02  3.758e-02  -0.355   0.7230    
V3.l5   1.013e+06  8.537e+05   1.187   0.2356    
V4.l5  -2.501e+05  3.766e+05  -0.664   0.5067    
V5.l5   5.286e+05  3.472e+05   1.522   0.1282    
V6.l5  -1.949e+06  8.411e+05  -2.317   0.0207 *  
V7.l5   3.748e-01  3.746e-02  10.006  < 2e-16 ***
V3.l6  -1.229e+05  8.581e+05  -0.143   0.8861    
V4.l6  -1.658e+05  3.756e+05  -0.442   0.6589    
V5.l6  -3.440e+05  3.478e+05  -0.989   0.3229    
V6.l6  -6.986e+05  8.531e+05  -0.819   0.4130    
V7.l6  -7.677e-02  3.744e-02  -2.050   0.0406 *  
V3.l7  -9.764e+05  8.523e+05  -1.146   0.2523    
V4.l7   4.369e+05  3.758e+05   1.163   0.2453    
V5.l7   1.690e+05  3.481e+05   0.485   0.6276    
V6.l7  -5.993e+04  8.558e+05  -0.070   0.9442    
V7.l7  -6.295e-02  3.744e-02  -1.681   0.0930 .  
V3.l8  -4.692e+05  8.582e+05  -0.547   0.5846    
V4.l8   4.179e+05  3.757e+05   1.112   0.2662    
V5.l8   5.177e+05  3.482e+05   1.487   0.1374    
V6.l8   3.444e+04  8.528e+05   0.040   0.9678    
V7.l8   1.138e-02  3.724e-02   0.305   0.7601    
V3.l9  -1.097e+06  8.569e+05  -1.280   0.2008    
V4.l9  -3.034e+05  3.762e+05  -0.806   0.4203    
V5.l9  -2.661e+05  3.492e+05  -0.762   0.4463    
V6.l9   8.136e+05  8.603e+05   0.946   0.3445    
V7.l9   7.410e-03  3.691e-02   0.201   0.8409    
V3.l10 -7.367e+04  3.278e+05  -0.225   0.8222    
V4.l10 -1.570e+05  3.773e+05  -0.416   0.6774    
V5.l10  4.374e+05  3.491e+05   1.253   0.2105    
V6.l10  8.825e+05  8.574e+05   1.029   0.3036    
V7.l10  7.415e-02  3.463e-02   2.141   0.0325 *  
const   6.062e+04  3.307e+04   1.833   0.0671 .  
trend   1.057e+01  5.334e+00   1.981   0.0479 *  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


Residual standard error: 30750 on 934 degrees of freedom
Multiple R-Squared: 0.7602,	Adjusted R-squared: 0.7471 
F-statistic: 58.06 on 51 and 934 DF,  p-value: < 2.2e-16 



Covariance matrix of residuals:
           V3        V4         V5         V6         V7
V3  1.696e-06 1.916e-06  1.985e-06  2.317e-06 -1.072e+00
V4  1.916e-06 2.489e-05  1.241e-05  2.951e-05  2.352e+01
V5  1.985e-06 1.241e-05  4.630e-05  4.676e-05 -5.108e+01
V6  2.317e-06 2.951e-05  4.676e-05  6.881e-05 -1.904e+01
V7 -1.072e+00 2.352e+01 -5.108e+01 -1.904e+01  9.458e+08

Correlation matrix of residuals:
         V3     V4      V5       V6       V7
V3  1.00000 0.2949  0.2240  0.21444 -0.02676
V4  0.29492 1.0000  0.3655  0.71301  0.15328
V5  0.22403 0.3655  1.0000  0.82829 -0.24409
V6  0.21444 0.7130  0.8283  1.00000 -0.07464
V7 -0.02676 0.1533 -0.2441 -0.07464  1.00000


> 
> fitvar1 = VAR(lr, p=10, type="both")
> 
> # auto correlation function for residuals for close price
> 
> acf(residuals(fitvar1)[,4])
> 
> # auto correlation function for residuals for open, high and low price
> 
> acf(residuals(fitvar1)[,1])
> 
> acf(residuals(fitvar1)[,2])
> 
> acf(residuals(fitvar1)[,3])
> 
> #vector auto regression of Open, High, Low and Close
> 
> #predict the next 10 values
> 
> var.pred <- predict(fitvar1, n.ahead=3, ci=0.95)
> 
> var.pred
$V3
         fcst    lower    upper          CI
[1,] 1.332669 1.330116 1.335221 0.002552364
[2,] 1.333993 1.316781 1.351204 0.017211745
[3,] 1.333547 1.309619 1.357475 0.023928297

$V4
         fcst    lower    upper          CI
[1,] 1.341456 1.331678 1.351234 0.009778128
[2,] 1.341383 1.321789 1.360978 0.019594577
[3,] 1.342218 1.316616 1.367819 0.025601667

$V5
         fcst    lower    upper         CI
[1,] 1.326643 1.313306 1.339979 0.01333679
[2,] 1.325935 1.304385 1.347485 0.02155004
[3,] 1.325274 1.297976 1.352572 0.02729799

$V6
         fcst    lower    upper         CI
[1,] 1.334641 1.318382 1.350900 0.01625882
[2,] 1.333610 1.310357 1.356863 0.02325269
[3,] 1.335006 1.306402 1.363610 0.02860379

$V7
         fcst    lower    upper       CI
[1,] 112702.0 52424.20 172979.7 60277.75
[2,] 107960.4 43233.35 172687.4 64727.03
[3,] 119106.5 51915.36 186297.6 67191.10

> 
> quotes[(x-4):x,]
             V1    V2      V3      V4      V5      V6     V7
2052 2016.08.04 00:00 1.33255 1.33450 1.31027 1.31072 120701
2053 2016.08.05 00:00 1.31037 1.31751 1.30216 1.30762  96414
2054 2016.08.08 00:00 1.30809 1.30969 1.30280 1.30401  71881
2055 2016.08.09 00:00 1.30407 1.30486 1.29560 1.30021  84611
2056 2016.08.10 00:00 1.30051 1.30941 1.29945 1.30280  74582

Now you can check above the predicted closing price is 1.33464 while the actual closing price is 1.31072. So the prediction is way off the mark. VAR model is not good for the daily timeframe as well as the weekly timeframe. Why? Keep this in mind that price relationship is highly non linear while VAR is a linear model. So most of the time this model will not be able to capture the non linearity in price.

H4 Candle Prediction Using VAR Model

> # Import the csv file
> quotes <- read.csv("E:/MarketData/GBPUSD240.csv", header=FALSE)
> 
> 
> x <-nrow(quotes)
> 
> lr <- quotes[(x-1000):(x-5),3:7]
> 
> 
> #install vars package
> 
> library(vars)
> 
> summary(VAR(lr, p=10, type="both"))

VAR Estimation Results:
========================= 
Endogenous variables: V3, V4, V5, V6, V7 
Deterministic variables: both 
Sample size: 986 
Log Likelihood: 9436.685 
Roots of the characteristic polynomial:
0.9896 0.9896 0.988 0.9771 0.9028 0.8803 0.8502 0.8502 0.8499 0.8499 0.8335 0.8335 0.8311 0.8311 0.8173 0.8173 0.8098 0.8098 0.8072 0.8072 0.7951 0.7951 0.7832 0.7832 0.7826 0.7826 0.7796 0.7796 0.7778 0.7778 0.7774 0.7774 0.7714 0.7701 0.7701 0.7547 0.7547 0.7461 0.7461 0.6952 0.6952 0.6634 0.6634 0.6049 0.6049 0.5589 0.5589 0.5488 0.5488 0.1861
Call:
VAR(y = lr, p = 10, type = "both")


Estimation results for equation V3: 
=================================== 
V3 = V3.l1 + V4.l1 + V5.l1 + V6.l1 + V7.l1 + V3.l2 + V4.l2 + V5.l2 + V6.l2 + V7.l2 + V3.l3 + V4.l3 + V5.l3 + V6.l3 + V7.l3 + V3.l4 + V4.l4 + V5.l4 + V6.l4 + V7.l4 + V3.l5 + V4.l5 + V5.l5 + V6.l5 + V7.l5 + V3.l6 + V4.l6 + V5.l6 + V6.l6 + V7.l6 + V3.l7 + V4.l7 + V5.l7 + V6.l7 + V7.l7 + V3.l8 + V4.l8 + V5.l8 + V6.l8 + V7.l8 + V3.l9 + V4.l9 + V5.l9 + V6.l9 + V7.l9 + V3.l10 + V4.l10 + V5.l10 + V6.l10 + V7.l10 + const + trend 

         Estimate Std. Error t value Pr(>|t|)    
V3.l1  -1.037e-01  3.453e-02  -3.003 0.002748 ** 
V4.l1   1.417e-02  1.355e-02   1.046 0.296059    
V5.l1   7.148e-03  1.378e-02   0.519 0.604168    
V6.l1   9.963e-01  1.406e-02  70.877  < 2e-16 ***
V7.l1   6.820e-10  5.010e-09   0.136 0.891763    
V3.l2  -2.832e-04  3.464e-02  -0.008 0.993479    
V4.l2  -4.638e-03  1.394e-02  -0.333 0.739342    
V5.l2   1.439e-02  1.439e-02   1.000 0.317613    
V6.l2   6.864e-02  3.597e-02   1.908 0.056674 .  
V7.l2  -4.326e-09  5.517e-09  -0.784 0.433168    
V3.l3  -8.623e-03  3.449e-02  -0.250 0.802651    
V4.l3  -1.653e-04  1.388e-02  -0.012 0.990498    
V5.l3  -1.455e-02  1.440e-02  -1.010 0.312834    
V6.l3   2.691e-02  3.591e-02   0.749 0.453842    
V7.l3   3.468e-09  5.509e-09   0.630 0.529131    
V3.l4   7.907e-02  3.444e-02   2.296 0.021896 *  
V4.l4   2.202e-03  1.381e-02   0.159 0.873365    
V5.l4  -1.102e-02  1.443e-02  -0.764 0.445163    
V6.l4  -2.170e-02  3.567e-02  -0.608 0.543219    
V7.l4   4.447e-09  5.321e-09   0.836 0.403504    
V3.l5  -1.896e-02  3.430e-02  -0.553 0.580555    
V4.l5  -9.700e-02  1.379e-02  -7.033 3.91e-12 ***
V5.l5   9.335e-02  1.436e-02   6.500 1.30e-10 ***
V6.l5   5.174e-03  3.558e-02   0.145 0.884400    
V7.l5   1.681e-08  4.422e-09   3.802 0.000153 ***
V3.l6   6.702e-03  2.851e-02   0.235 0.814221    
V4.l6  -8.106e-03  1.418e-02  -0.572 0.567714    
V5.l6   1.757e-02  1.465e-02   1.199 0.230715    
V6.l6  -1.948e-02  3.546e-02  -0.549 0.582846    
V7.l6  -2.532e-09  4.434e-09  -0.571 0.568130    
V3.l7  -7.122e-03  2.615e-02  -0.272 0.785413    
V4.l7   1.663e-02  1.422e-02   1.170 0.242278    
V5.l7  -4.681e-03  1.479e-02  -0.316 0.751718    
V6.l7  -3.376e-02  2.958e-02  -1.141 0.254041    
V7.l7   2.606e-09  5.390e-09   0.484 0.628813    
V3.l8  -5.688e-02  2.621e-02  -2.170 0.030268 *  
V4.l8   2.543e-02  1.418e-02   1.794 0.073195 .  
V5.l8  -1.678e-02  1.471e-02  -1.141 0.254291    
V6.l8   1.446e-02  2.737e-02   0.528 0.597325    
V7.l8  -5.162e-09  5.525e-09  -0.934 0.350409    
V3.l9   3.163e-03  2.591e-02   0.122 0.902853    
V4.l9  -7.183e-03  1.421e-02  -0.505 0.613355    
V5.l9   5.744e-04  1.472e-02   0.039 0.968874    
V6.l9   3.546e-02  2.740e-02   1.294 0.195974    
V7.l9  -6.583e-09  5.527e-09  -1.191 0.233992    
V3.l10 -6.957e-03  1.158e-02  -0.601 0.548160    
V4.l10  2.902e-02  1.377e-02   2.108 0.035300 *  
V5.l10 -3.057e-04  1.408e-02  -0.022 0.982678    
V6.l10 -1.507e-02  2.719e-02  -0.554 0.579540    
V7.l10 -5.012e-09  5.016e-09  -0.999 0.317964    
const   9.394e-04  8.722e-04   1.077 0.281736    
trend   1.526e-07  1.082e-07   1.411 0.158608    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


Residual standard error: 0.0006991 on 934 degrees of freedom
Multiple R-Squared: 0.9998,	Adjusted R-squared: 0.9998 
F-statistic: 1.035e+05 on 51 and 934 DF,  p-value: < 2.2e-16 


Estimation results for equation V4: 
=================================== 
V4 = V3.l1 + V4.l1 + V5.l1 + V6.l1 + V7.l1 + V3.l2 + V4.l2 + V5.l2 + V6.l2 + V7.l2 + V3.l3 + V4.l3 + V5.l3 + V6.l3 + V7.l3 + V3.l4 + V4.l4 + V5.l4 + V6.l4 + V7.l4 + V3.l5 + V4.l5 + V5.l5 + V6.l5 + V7.l5 + V3.l6 + V4.l6 + V5.l6 + V6.l6 + V7.l6 + V3.l7 + V4.l7 + V5.l7 + V6.l7 + V7.l7 + V3.l8 + V4.l8 + V5.l8 + V6.l8 + V7.l8 + V3.l9 + V4.l9 + V5.l9 + V6.l9 + V7.l9 + V3.l10 + V4.l10 + V5.l10 + V6.l10 + V7.l10 + const + trend 

         Estimate Std. Error t value Pr(>|t|)    
V3.l1   1.867e-01  1.498e-01   1.246  0.21305    
V4.l1   2.615e-01  5.878e-02   4.449 9.66e-06 ***
V5.l1  -1.529e-01  5.980e-02  -2.556  0.01073 *  
V6.l1   8.369e-01  6.099e-02  13.723  < 2e-16 ***
V7.l1  -1.827e-08  2.174e-08  -0.841  0.40077    
V3.l2   1.987e-01  1.503e-01   1.322  0.18640    
V4.l2  -5.715e-02  6.046e-02  -0.945  0.34478    
V5.l2  -1.485e-01  6.242e-02  -2.379  0.01756 *  
V6.l2   6.441e-03  1.561e-01   0.041  0.96709    
V7.l2  -1.395e-08  2.394e-08  -0.583  0.56012    
V3.l3   1.987e-01  1.497e-01   1.328  0.18451    
V4.l3  -1.652e-02  6.021e-02  -0.274  0.78390    
V5.l3  -1.091e-02  6.249e-02  -0.175  0.86145    
V6.l3  -8.968e-02  1.558e-01  -0.576  0.56500    
V7.l3  -3.601e-09  2.390e-08  -0.151  0.88029    
V3.l4   8.586e-02  1.494e-01   0.575  0.56564    
V4.l4  -1.257e-01  5.993e-02  -2.097  0.03622 *  
V5.l4  -1.263e-01  6.259e-02  -2.018  0.04384 *  
V6.l4  -9.618e-02  1.548e-01  -0.621  0.53447    
V7.l4   1.666e-08  2.309e-08   0.722  0.47067    
V3.l5  -2.921e-02  1.488e-01  -0.196  0.84442    
V4.l5  -6.779e-02  5.984e-02  -1.133  0.25755    
V5.l5   1.024e-01  6.231e-02   1.643  0.10070    
V6.l5   1.214e-01  1.544e-01   0.786  0.43192    
V7.l5   2.520e-08  1.918e-08   1.314  0.18929    
V3.l6   7.593e-02  1.237e-01   0.614  0.53949    
V4.l6  -2.472e-02  6.152e-02  -0.402  0.68797    
V5.l6  -4.074e-02  6.356e-02  -0.641  0.52168    
V6.l6  -1.102e-02  1.538e-01  -0.072  0.94293    
V7.l6   3.820e-08  1.924e-08   1.986  0.04737 *  
V3.l7  -2.973e-01  1.135e-01  -2.620  0.00893 ** 
V4.l7  -2.097e-02  6.168e-02  -0.340  0.73396    
V5.l7  -3.466e-02  6.417e-02  -0.540  0.58928    
V6.l7  -7.907e-02  1.283e-01  -0.616  0.53795    
V7.l7   1.849e-09  2.338e-08   0.079  0.93699    
V3.l8   2.285e-02  1.137e-01   0.201  0.84082    
V4.l8   2.888e-02  6.151e-02   0.469  0.63884    
V5.l8  -3.901e-02  6.382e-02  -0.611  0.54118    
V6.l8   3.719e-01  1.187e-01   3.133  0.00179 ** 
V7.l8  -9.722e-09  2.397e-08  -0.406  0.68515    
V3.l9  -1.176e-01  1.124e-01  -1.046  0.29566    
V4.l9  -4.954e-03  6.165e-02  -0.080  0.93597    
V5.l9  -2.734e-03  6.385e-02  -0.043  0.96586    
V6.l9  -1.201e-02  1.189e-01  -0.101  0.91953    
V7.l9  -4.428e-08  2.398e-08  -1.847  0.06512 .  
V3.l10  1.182e-02  5.024e-02   0.235  0.81400    
V4.l10 -1.088e-02  5.974e-02  -0.182  0.85551    
V5.l10 -7.017e-02  6.107e-02  -1.149  0.25085    
V6.l10  1.743e-01  1.180e-01   1.478  0.13987    
V7.l10  4.819e-09  2.176e-08   0.221  0.82480    
const   4.270e-03  3.784e-03   1.128  0.25943    
trend   7.916e-07  4.693e-07   1.687  0.09200 .  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


Residual standard error: 0.003033 on 934 degrees of freedom
Multiple R-Squared: 0.9966,	Adjusted R-squared: 0.9964 
F-statistic:  5395 on 51 and 934 DF,  p-value: < 2.2e-16 


Estimation results for equation V5: 
=================================== 
V5 = V3.l1 + V4.l1 + V5.l1 + V6.l1 + V7.l1 + V3.l2 + V4.l2 + V5.l2 + V6.l2 + V7.l2 + V3.l3 + V4.l3 + V5.l3 + V6.l3 + V7.l3 + V3.l4 + V4.l4 + V5.l4 + V6.l4 + V7.l4 + V3.l5 + V4.l5 + V5.l5 + V6.l5 + V7.l5 + V3.l6 + V4.l6 + V5.l6 + V6.l6 + V7.l6 + V3.l7 + V4.l7 + V5.l7 + V6.l7 + V7.l7 + V3.l8 + V4.l8 + V5.l8 + V6.l8 + V7.l8 + V3.l9 + V4.l9 + V5.l9 + V6.l9 + V7.l9 + V3.l10 + V4.l10 + V5.l10 + V6.l10 + V7.l10 + const + trend 

         Estimate Std. Error t value Pr(>|t|)    
V3.l1  -5.862e-02  2.342e-01  -0.250  0.80242    
V4.l1  -2.930e-01  9.191e-02  -3.188  0.00148 ** 
V5.l1   6.265e-01  9.349e-02   6.701 3.58e-11 ***
V6.l1   7.544e-01  9.535e-02   7.912 7.16e-15 ***
V7.l1   1.955e-08  3.399e-08   0.575  0.56527    
V3.l2   7.000e-02  2.350e-01   0.298  0.76583    
V4.l2   1.559e-01  9.453e-02   1.649  0.09949 .  
V5.l2  -2.304e-01  9.759e-02  -2.361  0.01842 *  
V6.l2  -2.050e-02  2.440e-01  -0.084  0.93305    
V7.l2  -2.204e-08  3.742e-08  -0.589  0.55608    
V3.l3   3.358e-01  2.340e-01   1.435  0.15157    
V4.l3  -3.799e-02  9.413e-02  -0.404  0.68660    
V5.l3   2.207e-01  9.770e-02   2.259  0.02411 *  
V6.l3  -1.128e-01  2.436e-01  -0.463  0.64325    
V7.l3   1.193e-08  3.737e-08   0.319  0.74966    
V3.l4   9.250e-02  2.336e-01   0.396  0.69220    
V4.l4  -1.414e-01  9.369e-02  -1.509  0.13172    
V5.l4  -2.187e-01  9.786e-02  -2.234  0.02569 *  
V6.l4  -3.167e-01  2.420e-01  -1.309  0.19094    
V7.l4  -8.423e-08  3.610e-08  -2.334  0.01983 *  
V3.l5  -3.966e-01  2.327e-01  -1.704  0.08863 .  
V4.l5   6.291e-02  9.356e-02   0.672  0.50149    
V5.l5   1.890e-01  9.742e-02   1.941  0.05262 .  
V6.l5   1.466e-01  2.413e-01   0.608  0.54360    
V7.l5   3.859e-08  2.999e-08   1.287  0.19851    
V3.l6  -6.720e-02  1.934e-01  -0.347  0.72831    
V4.l6  -1.019e-01  9.619e-02  -1.060  0.28947    
V5.l6  -2.023e-01  9.937e-02  -2.036  0.04202 *  
V6.l6   3.183e-01  2.405e-01   1.323  0.18603    
V7.l6  -5.574e-08  3.008e-08  -1.853  0.06420 .  
V3.l7  -1.416e-01  1.774e-01  -0.798  0.42489    
V4.l7  -1.737e-01  9.644e-02  -1.801  0.07201 .  
V5.l7   1.918e-01  1.003e-01   1.911  0.05627 .  
V6.l7   1.216e-01  2.006e-01   0.606  0.54460    
V7.l7   6.025e-08  3.656e-08   1.648  0.09970 .  
V3.l8  -1.668e-01  1.778e-01  -0.938  0.34833    
V4.l8   2.354e-01  9.617e-02   2.448  0.01455 *  
V5.l8  -6.005e-02  9.978e-02  -0.602  0.54744    
V6.l8   1.347e-01  1.856e-01   0.726  0.46815    
V7.l8  -4.564e-08  3.748e-08  -1.218  0.22356    
V3.l9   3.909e-02  1.757e-01   0.222  0.82405    
V4.l9  -1.251e-01  9.639e-02  -1.298  0.19469    
V5.l9   1.235e-01  9.983e-02   1.237  0.21630    
V6.l9   5.619e-02  1.859e-01   0.302  0.76249    
V7.l9   7.502e-08  3.749e-08   2.001  0.04568 *  
V3.l10  7.762e-02  7.855e-02   0.988  0.32331    
V4.l10 -1.006e-01  9.340e-02  -1.077  0.28162    
V5.l10 -9.781e-02  9.548e-02  -1.024  0.30595    
V6.l10  1.029e-01  1.845e-01   0.558  0.57724    
V7.l10  3.770e-09  3.403e-08   0.111  0.91179    
const   1.237e-02  5.916e-03   2.090  0.03688 *  
trend  -7.838e-07  7.337e-07  -1.068  0.28573    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


Residual standard error: 0.004742 on 934 degrees of freedom
Multiple R-Squared: 0.992,	Adjusted R-squared: 0.9916 
F-statistic:  2273 on 51 and 934 DF,  p-value: < 2.2e-16 


Estimation results for equation V6: 
=================================== 
V6 = V3.l1 + V4.l1 + V5.l1 + V6.l1 + V7.l1 + V3.l2 + V4.l2 + V5.l2 + V6.l2 + V7.l2 + V3.l3 + V4.l3 + V5.l3 + V6.l3 + V7.l3 + V3.l4 + V4.l4 + V5.l4 + V6.l4 + V7.l4 + V3.l5 + V4.l5 + V5.l5 + V6.l5 + V7.l5 + V3.l6 + V4.l6 + V5.l6 + V6.l6 + V7.l6 + V3.l7 + V4.l7 + V5.l7 + V6.l7 + V7.l7 + V3.l8 + V4.l8 + V5.l8 + V6.l8 + V7.l8 + V3.l9 + V4.l9 + V5.l9 + V6.l9 + V7.l9 + V3.l10 + V4.l10 + V5.l10 + V6.l10 + V7.l10 + const + trend 

         Estimate Std. Error t value Pr(>|t|)    
V3.l1   6.143e-02  2.705e-01   0.227  0.82042    
V4.l1   3.120e-03  1.062e-01   0.029  0.97656    
V5.l1   4.992e-01  1.080e-01   4.622 4.34e-06 ***
V6.l1   5.393e-01  1.101e-01   4.896 1.15e-06 ***
V7.l1   1.022e-08  3.926e-08   0.260  0.79468    
V3.l2   3.753e-01  2.714e-01   1.383  0.16712    
V4.l2   7.276e-02  1.092e-01   0.666  0.50536    
V5.l2  -2.912e-01  1.127e-01  -2.583  0.00994 ** 
V6.l2  -3.699e-03  2.819e-01  -0.013  0.98953    
V7.l2  -1.620e-08  4.323e-08  -0.375  0.70796    
V3.l3   5.037e-01  2.703e-01   1.863  0.06271 .  
V4.l3   5.418e-03  1.087e-01   0.050  0.96027    
V5.l3   1.728e-01  1.129e-01   1.531  0.12614    
V6.l3  -3.499e-01  2.814e-01  -1.243  0.21403    
V7.l3  -6.099e-09  4.317e-08  -0.141  0.88768    
V3.l4   1.073e-01  2.698e-01   0.398  0.69087    
V4.l4  -2.038e-01  1.082e-01  -1.883  0.05996 .  
V5.l4  -2.368e-01  1.130e-01  -2.094  0.03649 *  
V6.l4  -4.544e-01  2.795e-01  -1.626  0.10439    
V7.l4  -4.130e-08  4.170e-08  -0.990  0.32220    
V3.l5  -2.926e-01  2.688e-01  -1.088  0.27667    
V4.l5   1.135e-01  1.081e-01   1.050  0.29379    
V5.l5   1.755e-01  1.125e-01   1.559  0.11923    
V6.l5   2.073e-01  2.788e-01   0.744  0.45731    
V7.l5   3.454e-08  3.465e-08   0.997  0.31910    
V3.l6  -4.680e-02  2.234e-01  -0.209  0.83411    
V4.l6  -7.567e-02  1.111e-01  -0.681  0.49604    
V5.l6  -2.154e-01  1.148e-01  -1.876  0.06094 .  
V6.l6   1.749e-01  2.779e-01   0.630  0.52916    
V7.l6  -2.357e-08  3.475e-08  -0.678  0.49779    
V3.l7  -2.877e-01  2.049e-01  -1.404  0.16068    
V4.l7  -1.925e-01  1.114e-01  -1.728  0.08425 .  
V5.l7   2.428e-01  1.159e-01   2.095  0.03644 *  
V6.l7   2.674e-02  2.318e-01   0.115  0.90816    
V7.l7   7.484e-08  4.223e-08   1.772  0.07671 .  
V3.l8   3.902e-02  2.054e-01   0.190  0.84936    
V4.l8   2.676e-01  1.111e-01   2.409  0.01618 *  
V5.l8  -2.263e-02  1.153e-01  -0.196  0.84438    
V6.l8   2.070e-01  2.144e-01   0.965  0.33459    
V7.l8  -4.861e-08  4.329e-08  -1.123  0.26181    
V3.l9  -2.785e-02  2.030e-01  -0.137  0.89093    
V4.l9  -8.262e-02  1.114e-01  -0.742  0.45827    
V5.l9   1.045e-01  1.153e-01   0.906  0.36530    
V6.l9  -1.622e-01  2.147e-01  -0.755  0.45031    
V7.l9   1.587e-08  4.331e-08   0.366  0.71413    
V3.l10  1.076e-01  9.074e-02   1.186  0.23583    
V4.l10 -8.320e-02  1.079e-01  -0.771  0.44081    
V5.l10 -1.501e-01  1.103e-01  -1.361  0.17395    
V6.l10  1.609e-01  2.131e-01   0.755  0.45027    
V7.l10  1.089e-08  3.931e-08   0.277  0.78176    
const   1.696e-02  6.835e-03   2.481  0.01327 *  
trend  -3.600e-07  8.476e-07  -0.425  0.67116    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


Residual standard error: 0.005478 on 934 degrees of freedom
Multiple R-Squared: 0.9891,	Adjusted R-squared: 0.9885 
F-statistic:  1665 on 51 and 934 DF,  p-value: < 2.2e-16 


Estimation results for equation V7: 
=================================== 
V7 = V3.l1 + V4.l1 + V5.l1 + V6.l1 + V7.l1 + V3.l2 + V4.l2 + V5.l2 + V6.l2 + V7.l2 + V3.l3 + V4.l3 + V5.l3 + V6.l3 + V7.l3 + V3.l4 + V4.l4 + V5.l4 + V6.l4 + V7.l4 + V3.l5 + V4.l5 + V5.l5 + V6.l5 + V7.l5 + V3.l6 + V4.l6 + V5.l6 + V6.l6 + V7.l6 + V3.l7 + V4.l7 + V5.l7 + V6.l7 + V7.l7 + V3.l8 + V4.l8 + V5.l8 + V6.l8 + V7.l8 + V3.l9 + V4.l9 + V5.l9 + V6.l9 + V7.l9 + V3.l10 + V4.l10 + V5.l10 + V6.l10 + V7.l10 + const + trend 

         Estimate Std. Error t value Pr(>|t|)    
V3.l1  -1.274e+03  2.769e+05  -0.005  0.99633    
V4.l1   2.046e+05  1.087e+05   1.883  0.06004 .  
V5.l1  -1.854e+05  1.105e+05  -1.677  0.09390 .  
V6.l1  -3.199e+04  1.127e+05  -0.284  0.77668    
V7.l1   4.511e-01  4.019e-02  11.227  < 2e-16 ***
V3.l2  -2.431e+04  2.778e+05  -0.087  0.93030    
V4.l2  -2.200e+05  1.118e+05  -1.969  0.04930 *  
V5.l2   2.693e+04  1.154e+05   0.233  0.81550    
V6.l2   1.571e+05  2.885e+05   0.545  0.58618    
V7.l2   2.700e-02  4.425e-02   0.610  0.54190    
V3.l3  -2.750e+05  2.766e+05  -0.994  0.32041    
V4.l3  -3.928e+04  1.113e+05  -0.353  0.72423    
V5.l3  -1.132e+05  1.155e+05  -0.980  0.32746    
V6.l3   1.190e+05  2.880e+05   0.413  0.67954    
V7.l3  -1.076e-01  4.419e-02  -2.435  0.01509 *  
V3.l4   1.284e+05  2.762e+05   0.465  0.64216    
V4.l4   5.291e+04  1.108e+05   0.478  0.63306    
V5.l4   2.115e+04  1.157e+05   0.183  0.85497    
V6.l4   4.433e+05  2.861e+05   1.549  0.12160    
V7.l4   1.215e-01  4.268e-02   2.847  0.00451 ** 
V3.l5   1.319e+05  2.751e+05   0.479  0.63183    
V4.l5   5.867e+04  1.106e+05   0.530  0.59601    
V5.l5   3.046e+04  1.152e+05   0.264  0.79152    
V6.l5  -2.834e+05  2.854e+05  -0.993  0.32085    
V7.l5   5.727e-02  3.546e-02   1.615  0.10664    
V3.l6   4.160e+05  2.287e+05   1.819  0.06919 .  
V4.l6  -2.258e+05  1.137e+05  -1.985  0.04738 *  
V5.l6   5.037e+05  1.175e+05   4.287 2.00e-05 ***
V6.l6  -3.381e+05  2.844e+05  -1.189  0.23478    
V7.l6   6.820e-01  3.556e-02  19.177  < 2e-16 ***
V3.l7  -2.509e+05  2.097e+05  -1.196  0.23193    
V4.l7   3.214e+05  1.140e+05   2.818  0.00493 ** 
V5.l7  -1.147e+05  1.186e+05  -0.967  0.33397    
V6.l7  -6.141e+05  2.372e+05  -2.589  0.00979 ** 
V7.l7  -3.123e-01  4.323e-02  -7.224 1.05e-12 ***
V3.l8   1.497e+05  2.102e+05   0.712  0.47670    
V4.l8  -7.843e+04  1.137e+05  -0.690  0.49053    
V5.l8   5.199e+04  1.180e+05   0.441  0.65954    
V6.l8   1.576e+05  2.195e+05   0.718  0.47288    
V7.l8   4.220e-02  4.431e-02   0.952  0.34116    
V3.l9   6.332e+04  2.078e+05   0.305  0.76066    
V4.l9   2.956e+05  1.140e+05   2.594  0.00965 ** 
V5.l9   8.095e+03  1.180e+05   0.069  0.94534    
V6.l9  -3.422e+05  2.198e+05  -1.557  0.11981    
V7.l9  -2.162e-01  4.433e-02  -4.878 1.26e-06 ***
V3.l10 -2.747e+04  9.288e+04  -0.296  0.76748    
V4.l10  8.143e+04  1.104e+05   0.737  0.46106    
V5.l10  7.613e+04  1.129e+05   0.674  0.50025    
V6.l10 -3.288e+05  2.181e+05  -1.507  0.13203    
V7.l10  5.448e-02  4.023e-02   1.354  0.17606    
const  -3.542e+03  6.995e+03  -0.506  0.61276    
trend   1.028e+00  8.676e-01   1.185  0.23634    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


Residual standard error: 5607 on 934 degrees of freedom
Multiple R-Squared: 0.7962,	Adjusted R-squared: 0.785 
F-statistic: 71.53 on 51 and 934 DF,  p-value: < 2.2e-16 



Covariance matrix of residuals:
           V3        V4         V5         V6         V7
V3  4.888e-07 5.852e-07  5.053e-07  6.699e-07 -2.234e-01
V4  5.852e-07 9.201e-06  5.158e-06  1.082e-05  4.208e+00
V5  5.053e-07 5.158e-06  2.249e-05  2.298e-05 -1.058e+01
V6  6.699e-07 1.082e-05  2.298e-05  3.001e-05 -5.724e+00
V7 -2.234e-01 4.208e+00 -1.058e+01 -5.724e+00  3.144e+07

Correlation matrix of residuals:
         V3     V4      V5      V6       V7
V3  1.00000 0.2760  0.1524  0.1749 -0.05699
V4  0.27596 1.0000  0.3586  0.6513  0.24741
V5  0.15240 0.3586  1.0000  0.8845 -0.39769
V6  0.17491 0.6513  0.8845  1.0000 -0.18635
V7 -0.05699 0.2474 -0.3977 -0.1863  1.00000


> 
> fitvar1 = VAR(lr, p=10, type="both")
> 
> # auto correlation function for residuals for close price
> 
> acf(residuals(fitvar1)[,4])
> 
> # auto correlation function for residuals for open, high and low price
> 
> acf(residuals(fitvar1)[,1])
> 
> acf(residuals(fitvar1)[,2])
> 
> acf(residuals(fitvar1)[,3])
> 
> #vector auto regression of Open, High, Low and Close
> 
> #predict the next 10 values
> 
> var.pred <- predict(fitvar1, n.ahead=3, ci=0.95)
> 
> var.pred
$V3
         fcst    lower    upper          CI
[1,] 1.332577 1.331207 1.333947 0.001370293
[2,] 1.334250 1.323378 1.345123 0.010872588
[3,] 1.334271 1.319469 1.349074 0.014802333

$V4
         fcst    lower    upper          CI
[1,] 1.335382 1.329437 1.341327 0.005945184
[2,] 1.336633 1.325868 1.347398 0.010764925
[3,] 1.339282 1.324903 1.353661 0.014378940

$V5
         fcst    lower    upper          CI
[1,] 1.332261 1.322966 1.341556 0.009294972
[2,] 1.332014 1.316372 1.347656 0.015641808
[3,] 1.332158 1.313221 1.351096 0.018937874

$V6
         fcst    lower    upper         CI
[1,] 1.333983 1.323246 1.344721 0.01073738
[2,] 1.334070 1.319314 1.348826 0.01475552
[3,] 1.336536 1.318648 1.354424 0.01788796

$V7
          fcst     lower    upper       CI
[1,]  8565.783 -2424.409 19555.97 10990.19
[2,]  9851.751 -2771.602 22475.10 12623.35
[3,] 24147.332 11166.106 37128.56 12981.23

> 
> quotes[(x-4):x,]
              V1    V2      V3      V4      V5      V6    V7
10249 2016.08.04 00:00 1.33255 1.33444 1.33178 1.33364  6610
10250 2016.08.04 04:00 1.33363 1.33450 1.33234 1.33282  6478
10251 2016.08.04 08:00 1.33281 1.33290 1.32788 1.32944 21980
10252 2016.08.04 12:00 1.32946 1.33412 1.31124 1.31369 45662
10253 2016.08.04 16:00 1.31367 1.31460 1.31165 1.31273  5221

Now let’s see what are the predictions and what are the actuals. Actual Open, High, Low and Close is  1.33255, 1.33444. 1.33178 and 1.33364. The predicted Open, High, Low and Close is 1.33257, 1.33538, 1.33261 and 1.33398. The predicted values are pretty close to the actual values. So we have a good predictive model for H4 timeframe.

H1 Candle Prediction Using VAR Model

Below we check how good are the predictions for H1 candle!

> # Import the csv file
> quotes <- read.csv("E:/MarketData/GBPUSD60.csv", header=FALSE)
> 
> 
> x <-nrow(quotes)
> 
> lr <- quotes[(x-1000):(x-5),3:7]
> 
> 
> #install vars package
> 
> library(vars)
> 
> summary(VAR(lr, p=10, type="both"))

VAR Estimation Results:
========================= 
Endogenous variables: V3, V4, V5, V6, V7 
Deterministic variables: both 
Sample size: 986 
Log Likelihood: 11142.161 
Roots of the characteristic polynomial:
0.993 0.9659 0.9659 0.9014 0.8919 0.8919 0.8822 0.8822 0.8602 0.8602 0.8429 0.8429 0.842 0.842 0.8405 0.8405 0.8403 0.8403 0.8292 0.8292 0.8221 0.8221 0.8158 0.8158 0.8096 0.8096 0.7852 0.7852 0.7845 0.7845 0.7641 0.7641 0.7591 0.7591 0.7591 0.7591 0.7524 0.7524 0.7495 0.7495 0.7479 0.7479 0.7449 0.7449 0.725 0.725 0.5638 0.5586 0.5586 0.552
Call:
VAR(y = lr, p = 10, type = "both")


Estimation results for equation V3: 
=================================== 
V3 = V3.l1 + V4.l1 + V5.l1 + V6.l1 + V7.l1 + V3.l2 + V4.l2 + V5.l2 + V6.l2 + V7.l2 + V3.l3 + V4.l3 + V5.l3 + V6.l3 + V7.l3 + V3.l4 + V4.l4 + V5.l4 + V6.l4 + V7.l4 + V3.l5 + V4.l5 + V5.l5 + V6.l5 + V7.l5 + V3.l6 + V4.l6 + V5.l6 + V6.l6 + V7.l6 + V3.l7 + V4.l7 + V5.l7 + V6.l7 + V7.l7 + V3.l8 + V4.l8 + V5.l8 + V6.l8 + V7.l8 + V3.l9 + V4.l9 + V5.l9 + V6.l9 + V7.l9 + V3.l10 + V4.l10 + V5.l10 + V6.l10 + V7.l10 + const + trend 

         Estimate Std. Error t value Pr(>|t|)    
V3.l1   4.438e-03  3.728e-02   0.119 0.905256    
V4.l1  -6.359e-03  2.282e-02  -0.279 0.780580    
V5.l1   8.814e-03  1.788e-02   0.493 0.622079    
V6.l1   9.960e-01  1.998e-02  49.850  < 2e-16 ***
V7.l1   8.948e-09  1.746e-08   0.512 0.608439    
V3.l2   3.239e-02  3.712e-02   0.872 0.383220    
V4.l2  -2.060e-02  2.276e-02  -0.905 0.365647    
V5.l2  -3.047e-02  1.928e-02  -1.581 0.114269    
V6.l2   3.435e-02  3.800e-02   0.904 0.366360    
V7.l2  -1.885e-08  2.115e-08  -0.891 0.373010    
V3.l3  -1.946e-02  3.697e-02  -0.526 0.598782    
V4.l3  -2.882e-05  2.262e-02  -0.001 0.998984    
V5.l3  -4.139e-02  2.097e-02  -1.974 0.048703 *  
V6.l3   1.257e-02  3.809e-02   0.330 0.741537    
V7.l3   8.201e-09  2.133e-08   0.384 0.700713    
V3.l4  -6.095e-02  3.697e-02  -1.649 0.099570 .  
V4.l4   5.569e-02  2.234e-02   2.493 0.012833 *  
V5.l4   2.554e-02  2.189e-02   1.167 0.243566    
V6.l4  -1.451e-02  3.841e-02  -0.378 0.705613    
V7.l4  -4.947e-09  2.140e-08  -0.231 0.817260    
V3.l5   5.157e-02  3.697e-02   1.395 0.163454    
V4.l5  -2.074e-02  2.237e-02  -0.927 0.354166    
V5.l5   9.107e-02  2.169e-02   4.199 2.94e-05 ***
V6.l5  -5.097e-02  3.799e-02  -1.342 0.180012    
V7.l5   1.357e-08  2.135e-08   0.636 0.525017    
V3.l6   5.659e-03  3.626e-02   0.156 0.876018    
V4.l6  -1.431e-02  2.232e-02  -0.641 0.521771    
V5.l6  -2.967e-02  2.176e-02  -1.363 0.173149    
V6.l6  -2.392e-02  3.806e-02  -0.628 0.529832    
V7.l6  -1.296e-08  2.139e-08  -0.606 0.544732    
V3.l7   2.646e-02  3.625e-02   0.730 0.465588    
V4.l7  -8.082e-02  2.228e-02  -3.627 0.000303 ***
V5.l7  -3.216e-02  2.236e-02  -1.438 0.150679    
V6.l7   8.674e-02  3.741e-02   2.318 0.020646 *  
V7.l7   4.074e-08  2.142e-08   1.902 0.057455 .  
V3.l8   1.983e-02  3.587e-02   0.553 0.580438    
V4.l8  -2.340e-02  2.170e-02  -1.079 0.281088    
V5.l8   4.672e-02  2.196e-02   2.127 0.033682 *  
V6.l8  -2.632e-02  3.740e-02  -0.704 0.481757    
V7.l8  -3.263e-09  2.119e-08  -0.154 0.877636    
V3.l9   7.981e-02  3.570e-02   2.236 0.025620 *  
V4.l9  -1.102e-01  2.156e-02  -5.110 3.91e-07 ***
V5.l9  -5.239e-02  2.112e-02  -2.481 0.013288 *  
V6.l9   8.600e-02  3.680e-02   2.337 0.019665 *  
V7.l9   1.277e-08  2.115e-08   0.604 0.546185    
V3.l10  3.119e-02  1.902e-02   1.640 0.101345    
V4.l10  1.293e-02  2.064e-02   0.627 0.531081    
V5.l10 -1.069e-01  2.112e-02  -5.060 5.04e-07 ***
V6.l10  5.874e-02  3.629e-02   1.619 0.105882    
V7.l10 -3.487e-08  1.671e-08  -2.086 0.037227 *  
const  -1.288e-03  1.057e-03  -1.219 0.223260    
trend   1.162e-07  1.471e-07   0.790 0.429900    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


Residual standard error: 0.0008625 on 934 degrees of freedom
Multiple R-Squared: 0.9998,	Adjusted R-squared: 0.9998 
F-statistic: 8.027e+04 on 51 and 934 DF,  p-value: < 2.2e-16 


Estimation results for equation V4: 
=================================== 
V4 = V3.l1 + V4.l1 + V5.l1 + V6.l1 + V7.l1 + V3.l2 + V4.l2 + V5.l2 + V6.l2 + V7.l2 + V3.l3 + V4.l3 + V5.l3 + V6.l3 + V7.l3 + V3.l4 + V4.l4 + V5.l4 + V6.l4 + V7.l4 + V3.l5 + V4.l5 + V5.l5 + V6.l5 + V7.l5 + V3.l6 + V4.l6 + V5.l6 + V6.l6 + V7.l6 + V3.l7 + V4.l7 + V5.l7 + V6.l7 + V7.l7 + V3.l8 + V4.l8 + V5.l8 + V6.l8 + V7.l8 + V3.l9 + V4.l9 + V5.l9 + V6.l9 + V7.l9 + V3.l10 + V4.l10 + V5.l10 + V6.l10 + V7.l10 + const + trend 

         Estimate Std. Error t value Pr(>|t|)    
V3.l1   4.588e-02  9.153e-02   0.501 0.616294    
V4.l1   7.162e-03  5.604e-02   0.128 0.898325    
V5.l1  -7.112e-04  4.389e-02  -0.016 0.987075    
V6.l1   9.936e-01  4.906e-02  20.252  < 2e-16 ***
V7.l1   2.360e-07  4.287e-08   5.505 4.76e-08 ***
V3.l2   2.572e-01  9.115e-02   2.821 0.004882 ** 
V4.l2  -7.152e-03  5.589e-02  -0.128 0.898208    
V5.l2   1.404e-02  4.733e-02   0.297 0.766898    
V6.l2  -6.490e-02  9.331e-02  -0.696 0.486908    
V7.l2  -7.591e-08  5.193e-08  -1.462 0.144180    
V3.l3   1.613e-01  9.077e-02   1.777 0.075867 .  
V4.l3   4.700e-02  5.553e-02   0.846 0.397567    
V5.l3  -1.812e-01  5.150e-02  -3.520 0.000453 ***
V6.l3  -1.891e-01  9.353e-02  -2.022 0.043441 *  
V7.l3  -9.163e-08  5.237e-08  -1.750 0.080530 .  
V3.l4  -1.145e-01  9.078e-02  -1.261 0.207517    
V4.l4   1.224e-01  5.485e-02   2.231 0.025938 *  
V5.l4   4.819e-03  5.375e-02   0.090 0.928568    
V6.l4  -1.639e-01  9.431e-02  -1.738 0.082538 .  
V7.l4  -2.065e-08  5.255e-08  -0.393 0.694376    
V3.l5   8.916e-02  9.079e-02   0.982 0.326319    
V4.l5   6.277e-02  5.493e-02   1.143 0.253492    
V5.l5   1.631e-01  5.325e-02   3.063 0.002256 ** 
V6.l5  -1.408e-01  9.328e-02  -1.510 0.131462    
V7.l5   3.189e-08  5.241e-08   0.609 0.542960    
V3.l6   1.483e-01  8.904e-02   1.666 0.096125 .  
V4.l6  -1.863e-02  5.481e-02  -0.340 0.734029    
V5.l6  -3.543e-01  5.343e-02  -6.631 5.64e-11 ***
V6.l6   8.712e-02  9.344e-02   0.932 0.351397    
V7.l6  -8.830e-08  5.253e-08  -1.681 0.093071 .  
V3.l7   3.542e-02  8.902e-02   0.398 0.690815    
V4.l7  -1.384e-01  5.472e-02  -2.530 0.011563 *  
V5.l7   4.650e-03  5.489e-02   0.085 0.932515    
V6.l7   1.473e-01  9.186e-02   1.603 0.109175    
V7.l7   8.635e-08  5.258e-08   1.642 0.100916    
V3.l8   1.048e-01  8.808e-02   1.190 0.234223    
V4.l8   7.103e-03  5.328e-02   0.133 0.893965    
V5.l8   3.034e-02  5.393e-02   0.563 0.573900    
V6.l8  -4.870e-02  9.183e-02  -0.530 0.596040    
V7.l8  -7.383e-09  5.202e-08  -0.142 0.887159    
V3.l9  -1.012e-01  8.766e-02  -1.154 0.248674    
V4.l9  -5.861e-02  5.295e-02  -1.107 0.268619    
V5.l9   7.986e-03  5.186e-02   0.154 0.877647    
V6.l9  -2.641e-02  9.037e-02  -0.292 0.770147    
V7.l9   3.976e-08  5.193e-08   0.766 0.444022    
V3.l10 -6.842e-02  4.670e-02  -1.465 0.143212    
V4.l10  1.687e-01  5.068e-02   3.329 0.000907 ***
V5.l10 -3.109e-02  5.186e-02  -0.599 0.549012    
V6.l10  5.191e-05  8.911e-02   0.001 0.999535    
V7.l10 -1.038e-07  4.104e-08  -2.529 0.011592 *  
const  -1.719e-03  2.596e-03  -0.662 0.508088    
trend  -2.279e-07  3.612e-07  -0.631 0.528195    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


Residual standard error: 0.002118 on 934 degrees of freedom
Multiple R-Squared: 0.9986,	Adjusted R-squared: 0.9986 
F-statistic: 1.346e+04 on 51 and 934 DF,  p-value: < 2.2e-16 


Estimation results for equation V5: 
=================================== 
V5 = V3.l1 + V4.l1 + V5.l1 + V6.l1 + V7.l1 + V3.l2 + V4.l2 + V5.l2 + V6.l2 + V7.l2 + V3.l3 + V4.l3 + V5.l3 + V6.l3 + V7.l3 + V3.l4 + V4.l4 + V5.l4 + V6.l4 + V7.l4 + V3.l5 + V4.l5 + V5.l5 + V6.l5 + V7.l5 + V3.l6 + V4.l6 + V5.l6 + V6.l6 + V7.l6 + V3.l7 + V4.l7 + V5.l7 + V6.l7 + V7.l7 + V3.l8 + V4.l8 + V5.l8 + V6.l8 + V7.l8 + V3.l9 + V4.l9 + V5.l9 + V6.l9 + V7.l9 + V3.l10 + V4.l10 + V5.l10 + V6.l10 + V7.l10 + const + trend 

         Estimate Std. Error t value Pr(>|t|)    
V3.l1  -2.807e-01  1.443e-01  -1.945 0.052078 .  
V4.l1   1.546e-01  8.835e-02   1.749 0.080548 .  
V5.l1   6.578e-01  6.920e-02   9.506  < 2e-16 ***
V6.l1   4.983e-01  7.735e-02   6.442 1.88e-10 ***
V7.l1  -1.405e-07  6.759e-08  -2.079 0.037880 *  
V3.l2   2.739e-01  1.437e-01   1.906 0.056953 .  
V4.l2  -3.151e-02  8.812e-02  -0.358 0.720729    
V5.l2   6.902e-01  7.463e-02   9.248  < 2e-16 ***
V6.l2  -5.786e-01  1.471e-01  -3.933 9.02e-05 ***
V7.l2   2.790e-07  8.188e-08   3.408 0.000683 ***
V3.l3  -2.295e-01  1.431e-01  -1.603 0.109235    
V4.l3   1.747e-01  8.756e-02   1.995 0.046349 *  
V5.l3   3.498e-01  8.119e-02   4.308 1.82e-05 ***
V6.l3  -5.572e-01  1.475e-01  -3.778 0.000168 ***
V7.l3  -1.034e-07  8.258e-08  -1.252 0.210708    
V3.l4  -6.276e-02  1.431e-01  -0.438 0.661141    
V4.l4   4.878e-02  8.648e-02   0.564 0.572843    
V5.l4  -1.861e-01  8.474e-02  -2.196 0.028317 *  
V6.l4  -8.661e-02  1.487e-01  -0.582 0.560412    
V7.l4  -9.678e-08  8.286e-08  -1.168 0.243108    
V3.l5   2.084e-01  1.431e-01   1.456 0.145727    
V4.l5  -1.693e-01  8.661e-02  -1.954 0.050960 .  
V5.l5  -9.031e-03  8.397e-02  -0.108 0.914375    
V6.l5   7.572e-02  1.471e-01   0.515 0.606803    
V7.l5   1.812e-07  8.263e-08   2.193 0.028575 *  
V3.l6   2.408e-01  1.404e-01   1.715 0.086665 .  
V4.l6  -2.154e-01  8.643e-02  -2.493 0.012851 *  
V5.l6  -3.403e-01  8.425e-02  -4.039 5.81e-05 ***
V6.l6   2.949e-01  1.473e-01   2.001 0.045639 *  
V7.l6  -6.397e-08  8.282e-08  -0.772 0.440074    
V3.l7   7.131e-02  1.404e-01   0.508 0.611515    
V4.l7   5.537e-02  8.627e-02   0.642 0.521118    
V5.l7  -1.114e-02  8.655e-02  -0.129 0.897650    
V6.l7  -1.766e-02  1.448e-01  -0.122 0.902961    
V7.l7  -2.865e-08  8.291e-08  -0.346 0.729789    
V3.l8  -9.743e-02  1.389e-01  -0.702 0.483116    
V4.l8   9.449e-02  8.400e-02   1.125 0.260939    
V5.l8   1.554e-01  8.503e-02   1.828 0.067845 .  
V6.l8  -1.149e-01  1.448e-01  -0.793 0.427764    
V7.l8  -1.020e-08  8.201e-08  -0.124 0.901057    
V3.l9   8.082e-02  1.382e-01   0.585 0.558850    
V4.l9  -3.180e-02  8.348e-02  -0.381 0.703340    
V5.l9   1.428e-01  8.176e-02   1.746 0.081121 .  
V6.l9  -1.633e-01  1.425e-01  -1.146 0.252178    
V7.l9   1.050e-07  8.187e-08   1.283 0.199835    
V3.l10 -3.240e-02  7.363e-02  -0.440 0.659979    
V4.l10  1.352e-01  7.991e-02   1.692 0.090905 .  
V5.l10 -1.629e-01  8.176e-02  -1.992 0.046680 *  
V6.l10 -2.998e-02  1.405e-01  -0.213 0.831091    
V7.l10 -1.476e-07  6.470e-08  -2.281 0.022752 *  
const   7.157e-03  4.093e-03   1.749 0.080659 .  
trend  -6.186e-07  5.695e-07  -1.086 0.277605    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


Residual standard error: 0.003339 on 934 degrees of freedom
Multiple R-Squared: 0.9965,	Adjusted R-squared: 0.9963 
F-statistic:  5262 on 51 and 934 DF,  p-value: < 2.2e-16 


Estimation results for equation V6: 
=================================== 
V6 = V3.l1 + V4.l1 + V5.l1 + V6.l1 + V7.l1 + V3.l2 + V4.l2 + V5.l2 + V6.l2 + V7.l2 + V3.l3 + V4.l3 + V5.l3 + V6.l3 + V7.l3 + V3.l4 + V4.l4 + V5.l4 + V6.l4 + V7.l4 + V3.l5 + V4.l5 + V5.l5 + V6.l5 + V7.l5 + V3.l6 + V4.l6 + V5.l6 + V6.l6 + V7.l6 + V3.l7 + V4.l7 + V5.l7 + V6.l7 + V7.l7 + V3.l8 + V4.l8 + V5.l8 + V6.l8 + V7.l8 + V3.l9 + V4.l9 + V5.l9 + V6.l9 + V7.l9 + V3.l10 + V4.l10 + V5.l10 + V6.l10 + V7.l10 + const + trend 

         Estimate Std. Error t value Pr(>|t|)    
V3.l1  -1.664e-01  1.502e-01  -1.108 0.268104    
V4.l1   1.311e-01  9.195e-02   1.426 0.154319    
V5.l1   7.151e-01  7.202e-02   9.930  < 2e-16 ***
V6.l1   4.937e-01  8.050e-02   6.133 1.27e-09 ***
V7.l1   9.048e-08  7.034e-08   1.286 0.198646    
V3.l2   3.502e-01  1.496e-01   2.341 0.019432 *  
V4.l2   1.079e-02  9.171e-02   0.118 0.906387    
V5.l2   2.867e-01  7.767e-02   3.692 0.000236 ***
V6.l2  -5.274e-01  1.531e-01  -3.444 0.000598 ***
V7.l2   8.716e-08  8.521e-08   1.023 0.306654    
V3.l3  -3.517e-02  1.489e-01  -0.236 0.813393    
V4.l3   1.870e-01  9.112e-02   2.052 0.040418 *  
V5.l3   3.191e-01  8.450e-02   3.777 0.000169 ***
V6.l3  -5.392e-01  1.535e-01  -3.513 0.000464 ***
V7.l3  -5.424e-08  8.594e-08  -0.631 0.528081    
V3.l4  -1.454e-01  1.489e-01  -0.976 0.329251    
V4.l4   9.038e-02  9.000e-02   1.004 0.315518    
V5.l4  -1.731e-01  8.819e-02  -1.963 0.049924 *  
V6.l4  -1.513e-01  1.548e-01  -0.978 0.328466    
V7.l4  -6.207e-08  8.623e-08  -0.720 0.471804    
V3.l5   1.807e-01  1.490e-01   1.213 0.225387    
V4.l5  -7.290e-02  9.014e-02  -0.809 0.418866    
V5.l5   9.812e-02  8.738e-02   1.123 0.261794    
V6.l5  -8.835e-02  1.531e-01  -0.577 0.563937    
V7.l5   7.315e-08  8.599e-08   0.851 0.395222    
V3.l6   2.917e-01  1.461e-01   1.997 0.046135 *  
V4.l6  -1.359e-01  8.994e-02  -1.511 0.131117    
V5.l6  -6.472e-01  8.767e-02  -7.381 3.46e-13 ***
V6.l6   4.206e-01  1.533e-01   2.743 0.006205 ** 
V7.l6  -1.393e-07  8.619e-08  -1.616 0.106522    
V3.l7   8.693e-02  1.461e-01   0.595 0.551876    
V4.l7  -7.605e-02  8.978e-02  -0.847 0.397205    
V5.l7   3.043e-02  9.007e-02   0.338 0.735574    
V6.l7   5.473e-02  1.507e-01   0.363 0.716623    
V7.l7   1.021e-07  8.628e-08   1.183 0.237213    
V3.l8  -6.197e-02  1.445e-01  -0.429 0.668172    
V4.l8   1.019e-01  8.742e-02   1.166 0.243888    
V5.l8   1.065e-01  8.849e-02   1.204 0.229040    
V6.l8  -2.322e-02  1.507e-01  -0.154 0.877548    
V7.l8  -7.937e-08  8.535e-08  -0.930 0.352668    
V3.l9  -1.162e-01  1.438e-01  -0.808 0.419217    
V4.l9  -3.072e-02  8.688e-02  -0.354 0.723682    
V5.l9   9.215e-02  8.509e-02   1.083 0.279092    
V6.l9  -1.240e-01  1.483e-01  -0.836 0.403351    
V7.l9   1.039e-07  8.521e-08   1.219 0.223036    
V3.l10 -8.067e-02  7.662e-02  -1.053 0.292681    
V4.l10  1.467e-01  8.316e-02   1.764 0.077983 .  
V5.l10 -4.688e-02  8.509e-02  -0.551 0.581789    
V6.l10  4.479e-02  1.462e-01   0.306 0.759392    
V7.l10 -8.263e-08  6.734e-08  -1.227 0.220112    
const   4.242e-03  4.259e-03   0.996 0.319568    
trend  -6.731e-07  5.926e-07  -1.136 0.256290    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


Residual standard error: 0.003475 on 934 degrees of freedom
Multiple R-Squared: 0.9963,	Adjusted R-squared: 0.9961 
F-statistic:  4913 on 51 and 934 DF,  p-value: < 2.2e-16 


Estimation results for equation V7: 
=================================== 
V7 = V3.l1 + V4.l1 + V5.l1 + V6.l1 + V7.l1 + V3.l2 + V4.l2 + V5.l2 + V6.l2 + V7.l2 + V3.l3 + V4.l3 + V5.l3 + V6.l3 + V7.l3 + V3.l4 + V4.l4 + V5.l4 + V6.l4 + V7.l4 + V3.l5 + V4.l5 + V5.l5 + V6.l5 + V7.l5 + V3.l6 + V4.l6 + V5.l6 + V6.l6 + V7.l6 + V3.l7 + V4.l7 + V5.l7 + V6.l7 + V7.l7 + V3.l8 + V4.l8 + V5.l8 + V6.l8 + V7.l8 + V3.l9 + V4.l9 + V5.l9 + V6.l9 + V7.l9 + V3.l10 + V4.l10 + V5.l10 + V6.l10 + V7.l10 + const + trend 

         Estimate Std. Error t value Pr(>|t|)    
V3.l1  -5.531e+04  8.556e+04  -0.646 0.518196    
V4.l1  -5.090e+04  5.238e+04  -0.972 0.331471    
V5.l1  -1.131e+05  4.103e+04  -2.756 0.005966 ** 
V6.l1   1.151e+05  4.586e+04   2.509 0.012292 *  
V7.l1   7.999e-01  4.008e-02  19.960  < 2e-16 ***
V3.l2   2.077e+04  8.521e+04   0.244 0.807530    
V4.l2   8.262e+03  5.225e+04   0.158 0.874384    
V5.l2  -9.809e+04  4.425e+04  -2.217 0.026884 *  
V6.l2   1.681e+05  8.724e+04   1.927 0.054260 .  
V7.l2  -1.127e-01  4.855e-02  -2.321 0.020506 *  
V3.l3   1.033e+04  8.486e+04   0.122 0.903155    
V4.l3   1.402e+04  5.192e+04   0.270 0.787214    
V5.l3   1.750e+03  4.814e+04   0.036 0.971002    
V6.l3  -8.681e+03  8.744e+04  -0.099 0.920936    
V7.l3  -4.844e-02  4.896e-02  -0.989 0.322751    
V3.l4  -4.279e+04  8.486e+04  -0.504 0.614253    
V4.l4   2.059e+04  5.128e+04   0.401 0.688162    
V5.l4   5.766e+04  5.024e+04   1.148 0.251399    
V6.l4  -5.507e+04  8.817e+04  -0.625 0.532395    
V7.l4   2.976e-02  4.913e-02   0.606 0.544809    
V3.l5   3.251e+04  8.487e+04   0.383 0.701748    
V4.l5  -1.811e+04  5.135e+04  -0.353 0.724441    
V5.l5  -5.346e+03  4.978e+04  -0.107 0.914515    
V6.l5   3.998e+04  8.720e+04   0.458 0.646707    
V7.l5   7.042e-02  4.899e-02   1.437 0.150985    
V3.l6  -3.894e+04  8.324e+04  -0.468 0.640003    
V4.l6   1.325e+04  5.124e+04   0.259 0.796071    
V5.l6  -7.529e+04  4.995e+04  -1.507 0.132087    
V6.l6   3.656e+04  8.736e+04   0.419 0.675666    
V7.l6  -5.088e-02  4.910e-02  -1.036 0.300422    
V3.l7  -1.150e+04  8.322e+04  -0.138 0.890149    
V4.l7  -5.589e+04  5.115e+04  -1.093 0.274857    
V5.l7   1.979e+04  5.132e+04   0.386 0.699820    
V6.l7   4.654e+04  8.588e+04   0.542 0.587981    
V7.l7   9.150e-02  4.916e-02   1.861 0.062996 .  
V3.l8   9.021e+04  8.234e+04   1.096 0.273526    
V4.l8  -1.029e+04  4.981e+04  -0.207 0.836308    
V5.l8  -1.031e+05  5.042e+04  -2.046 0.041057 *  
V6.l8   9.273e+04  8.585e+04   1.080 0.280344    
V7.l8  -1.021e-01  4.863e-02  -2.100 0.036031 *  
V3.l9  -1.244e+05  8.195e+04  -1.518 0.129358    
V4.l9   3.253e+04  4.950e+04   0.657 0.511279    
V5.l9  -5.139e+04  4.848e+04  -1.060 0.289372    
V6.l9  -9.584e+03  8.448e+04  -0.113 0.909697    
V7.l9  -9.003e-02  4.854e-02  -1.855 0.063967 .  
V3.l10 -5.409e+04  4.366e+04  -1.239 0.215692    
V4.l10  1.000e+05  4.738e+04   2.111 0.035063 *  
V5.l10  1.467e+04  4.848e+04   0.303 0.762223    
V6.l10  4.759e+04  8.330e+04   0.571 0.567971    
V7.l10 -1.390e-01  3.836e-02  -3.622 0.000308 ***
const   1.546e+03  2.427e+03   0.637 0.524256    
trend  -9.065e-01  3.376e-01  -2.685 0.007385 ** 
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


Residual standard error: 1980 on 934 degrees of freedom
Multiple R-Squared: 0.7347,	Adjusted R-squared: 0.7202 
F-statistic: 50.71 on 51 and 934 DF,  p-value: < 2.2e-16 



Covariance matrix of residuals:
          V3        V4         V5         V6         V7
V3 7.440e-07 7.393e-07  7.004e-07  6.898e-07  8.406e-03
V4 7.393e-07 4.485e-06  2.198e-06  4.633e-06  1.386e+00
V5 7.004e-07 2.198e-06  1.115e-05  9.487e-06 -2.354e+00
V6 6.898e-07 4.633e-06  9.487e-06  1.208e-05 -6.411e-01
V7 8.406e-03 1.386e+00 -2.354e+00 -6.411e-01  3.920e+06

Correlation matrix of residuals:
         V3     V4      V5       V6        V7
V3 1.000000 0.4047  0.2432  0.23013  0.004922
V4 0.404717 1.0000  0.3108  0.62945  0.330465
V5 0.243168 0.3108  1.0000  0.81756 -0.356087
V6 0.230130 0.6294  0.8176  1.00000 -0.093179
V7 0.004922 0.3305 -0.3561 -0.09318  1.000000


> 
> fitvar1 = VAR(lr, p=10, type="both")
> 
> # auto correlation function for residuals for close price
> 
> acf(residuals(fitvar1)[,4])
> 
> # auto correlation function for residuals for open, high and low price
> 
> acf(residuals(fitvar1)[,1])
> 
> acf(residuals(fitvar1)[,2])
> 
> acf(residuals(fitvar1)[,3])
> 
> #vector auto regression of Open, High, Low and Close
> 
> #predict the next 10 values
> 
> var.pred <- predict(fitvar1, n.ahead=3, ci=0.95)
> 
> var.pred
$V3
         fcst    lower    upper          CI
[1,] 1.308923 1.307233 1.310614 0.001690542
[2,] 1.309417 1.302398 1.316437 0.007019716
[3,] 1.309859 1.299338 1.320380 0.010520951

$V4
         fcst    lower    upper          CI
[1,] 1.309923 1.305772 1.314074 0.004150918
[2,] 1.310630 1.302681 1.318578 0.007948780
[3,] 1.310900 1.299789 1.322010 0.011110588

$V5
         fcst    lower    upper          CI
[1,] 1.308566 1.302021 1.315111 0.006544701
[2,] 1.308913 1.298814 1.319012 0.010098650
[3,] 1.308848 1.295342 1.322355 0.013506637

$V6
         fcst    lower    upper          CI
[1,] 1.309337 1.302526 1.316148 0.006810988
[2,] 1.309749 1.299393 1.320106 0.010356437
[3,] 1.309778 1.296913 1.322642 0.012864717

$V7
         fcst      lower     upper       CI
[1,] 2955.973  -924.4980  6836.443 3880.471
[2,] 3783.907 -1276.8589  8844.672 5060.766
[3,] 4644.148  -976.3765 10264.673 5620.525

> 
> quotes[(x-4):x,]
             V1    V2      V3      V4      V5      V6   V7
5567 2016.08.08 06:00 1.30875 1.30897 1.30858 1.30871  976
5568 2016.08.08 07:00 1.30870 1.30881 1.30815 1.30852 1145
5569 2016.08.08 08:00 1.30851 1.30867 1.30805 1.30815 1279
5570 2016.08.08 09:00 1.30814 1.30862 1.30457 1.30512 3715
5571 2016.08.08 10:00 1.30516 1.30630 1.30456 1.30576 1748

Now once again we got very good predictions for H1 candle which are pretty close the actual values. I am omitting the M30 timeframe but the calculations will show you that this model can make good predictions on M30 as well.

Conclusion

The predictions on Weekly and Daily timeframe were not good. The most probable reason is the high non linear price patterns on weekly and daily timeframes. The predictions on H4, H1, M30, M15, M5 and M1 are pretty good. The most probable reason is that the non linear structure is not that strong on these timeframes. The time taken by R for these calculations is less 15 seconds. So you can use these predictions in day trading. You can also use these predictions in trading binary options.

0 Comments