The data for this R script comes from the Metatrader 4 platform (click on menu File-> Save As…).
There are SEVEN (7) columns in the CSV file: (1) Date; (2) Time; (3) Open; (4) High; (5) Low; (6) Close; and (7) Volume, and
there is NO header. The files for this script are as follows:
(1) EURUSD1.csv
(2) EURUSD5.csv
(3) EURUSD15.csv
(4) EURUSD30.csv
(5) EURUSD60.csv
(6) EURUSD240.csv
(7) EURUSD1440.csv
(8) EURUSD10080.csv
(9) EURUSD43200.csv
(1) Read the data.
(2) Plot the autocorrelation function.
library(chron)
library(zoo)
## Attaching package: 'zoo'
## The following object(s) are masked from 'package:base':
##
## as.Date, as.Date.numeric
library(PerformanceAnalytics)
## Loading required package: xts
## Attaching package: 'PerformanceAnalytics'
## The following object(s) are masked from 'package:graphics':
##
## legend
library(tseries)
## Loading required package: quadprog
## Attaching package: 'tseries'
## The following object(s) are masked from 'package:chron':
##
## is.weekend
#
# |------------------------------------------------------------------------------------------|
# | I N I T I A L I Z A T I O N |
# |------------------------------------------------------------------------------------------|
source("C:/Users/denbrige/100 FxOption/103 FxOptionVerBack/080 Fx Git/R-source/PlusBas.R",
echo = FALSE)
source("C:/Users/denbrige/100 FxOption/103 FxOptionVerBack/080 Fx Git/R-source/PlusForex.R",
echo = FALSE)
#
# |------------------------------------------------------------------------------------------|
# | M A I N P R O C E D U R E |
# |------------------------------------------------------------------------------------------|
# --- Assert symbol name
par(mfcol = c(5, 2), las = 2, mar = c(2.1, 5.1, 2.1, 2.1))
ForexAcfPlot("EURUSD")
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## -0.010 -0.002 -0.002 -0.001 0.004 -0.006 -0.003 0.000 0.001 0.005
## 11 12 13 14 15 16 17 18 19 20
## -0.001 -0.002 0.004 0.008 0.005 -0.002 0.004 -0.008 0.001 0.007
## [1] "EURUSD1"
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## -0.023 -0.001 0.011 0.003 -0.002 -0.002 0.002 -0.007 0.002 -0.008
## 11 12 13 14 15 16 17 18 19 20
## 0.000 -0.001 -0.006 0.001 -0.008 0.003 -0.004 -0.006 0.005 0.005
## [1] "EURUSD5"
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## 0.011 -0.008 -0.016 -0.009 -0.004 -0.006 0.010 0.008 0.021 0.025
## 11 12 13 14 15 16 17 18 19 20
## -0.009 0.002 -0.007 -0.008 -0.008 0.020 0.007 -0.007 0.000 -0.008
## [1] "EURUSD15"
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## 0.021 -0.025 -0.002 0.015 0.009 -0.013 -0.018 0.027 -0.006 0.000
## 11 12 13 14 15 16 17 18 19 20
## -0.017 0.009 0.004 -0.004 -0.007 0.012 0.006 -0.003 0.005 -0.002
## [1] "EURUSD30"
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## -0.020 0.033 -0.018 0.019 -0.026 0.001 0.006 0.009 0.010 0.003
## 11 12 13 14 15 16 17 18 19 20
## 0.001 0.003 -0.019 0.010 -0.012 -0.018 0.001 0.001 -0.001 0.012
## [1] "EURUSD60"
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## -0.032 0.004 0.006 0.019 0.004 -0.049 0.010 0.013 -0.017 -0.015
## 11 12 13 14 15 16 17 18 19 20
## -0.014 0.036 0.005 -0.022 0.019 -0.023 0.025 -0.027 -0.022 -0.004
## [1] "EURUSD240"
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## 0.006 -0.003 -0.029 0.015 0.002 0.032 -0.002 0.027 -0.051 0.011
## 11 12 13 14 15 16 17 18 19 20
## 0.005 -0.003 0.028 0.020 0.041 0.001 0.029 0.015 -0.017 -0.012
## [1] "EURUSD1440"
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## 0.000 0.021 0.003 0.058 0.025 -0.052 -0.038 0.017 -0.048 -0.025
## 11 12 13 14 15 16 17 18 19 20
## 0.027 -0.026 0.028 0.039 -0.005 -0.032 -0.007 0.024 -0.016 0.000
## [1] "EURUSD10080"
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## 0.064 -0.049 0.062 -0.101 -0.016 0.036 -0.066 0.056 0.056 0.008
## 11 12 13 14 15 16 17 18 19 20
## -0.025 -0.048 -0.078 -0.037 -0.021 0.047 0.083 0.049 0.037 -0.054
## [1] "EURUSD43200"
par(mfcol = c(5, 2), las = 2, mar = c(2.1, 5.1, 2.1, 2.1))
ForexAcfPlot("AUDUSD")
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## -0.100 -0.002 0.000 -0.050 0.026 -0.087 0.023 -0.043 0.003 -0.012
## 11 12 13 14 15 16 17 18 19 20
## 0.001 -0.025 -0.003 0.020 0.024 -0.013 -0.012 0.012 -0.010 0.044
## [1] "AUDUSD1"
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## -0.088 -0.061 0.010 -0.027 0.024 0.003 -0.036 -0.003 0.013 -0.011
## 11 12 13 14 15 16 17 18 19 20
## -0.033 0.039 -0.026 -0.027 0.024 -0.036 -0.013 0.052 -0.012 0.008
## [1] "AUDUSD5"
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## -0.051 -0.030 -0.011 -0.019 0.004 0.055 0.005 0.003 0.013 -0.018
## 11 12 13 14 15 16 17 18 19 20
## -0.041 -0.015 0.000 -0.020 0.029 0.042 0.024 -0.005 -0.022 -0.031
## [1] "AUDUSD15"
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## -0.055 0.006 -0.004 0.020 0.008 0.011 -0.004 0.055 -0.033 -0.041
## 11 12 13 14 15 16 17 18 19 20
## -0.011 0.017 0.012 0.075 0.020 0.026 -0.023 0.009 0.000 0.018
## [1] "AUDUSD30"
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## -0.028 0.021 -0.001 0.023 -0.017 -0.001 0.078 0.032 0.039 -0.021
## 11 12 13 14 15 16 17 18 19 20
## 0.013 -0.018 -0.007 -0.010 -0.006 -0.023 -0.011 0.022 -0.011 0.016
## [1] "AUDUSD60"
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## -0.022 0.038 0.024 0.027 -0.014 -0.073 0.027 -0.003 -0.006 -0.003
## 11 12 13 14 15 16 17 18 19 20
## 0.031 0.018 0.037 -0.025 0.040 0.010 0.034 -0.027 -0.040 -0.015
## [1] "AUDUSD240"
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## -0.044 0.005 -0.030 0.053 -0.047 -0.053 0.038 0.038 -0.051 -0.016
## 11 12 13 14 15 16 17 18 19 20
## 0.026 0.010 0.063 -0.027 -0.008 -0.023 0.034 -0.021 0.003 -0.026
## [1] "AUDUSD1440"
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## -0.038 0.047 -0.050 -0.001 0.030 0.042 -0.013 0.058 -0.037 -0.063
## 11 12 13 14 15 16 17 18 19 20
## -0.025 -0.007 0.064 0.058 0.010 0.030 -0.009 -0.021 0.018 0.007
## [1] "AUDUSD10080"
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## 0.041 -0.049 0.149 -0.005 -0.025 0.041 -0.077 -0.070 -0.065 0.056
## 11 12 13 14 15 16 17 18 19 20
## -0.002 -0.061 -0.109 0.044 0.029 0.009 -0.012 -0.039 0.091 0.008
## [1] "AUDUSD43200"
par(mfcol = c(5, 2), las = 2, mar = c(2.1, 5.1, 2.1, 2.1))
ForexAcfPlot("USDCAD")
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## -0.030 0.009 0.038 0.003 0.005 -0.011 0.022 -0.050 -0.047 0.032
## 11 12 13 14 15 16 17 18 19 20
## 0.054 -0.018 0.028 -0.009 0.007 0.022 -0.008 0.009 -0.029 0.038
## [1] "USDCAD1"
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## -0.031 0.008 0.012 -0.043 0.032 0.019 0.004 -0.009 -0.020 0.007
## 11 12 13 14 15 16 17 18 19 20
## 0.020 0.007 0.030 -0.026 0.011 -0.047 0.017 0.026 0.012 -0.009
## [1] "USDCAD5"
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## -0.013 0.002 -0.024 0.000 -0.009 0.016 0.019 0.008 -0.003 -0.021
## 11 12 13 14 15 16 17 18 19 20
## -0.021 0.014 -0.014 0.001 -0.006 0.028 0.020 -0.005 -0.022 -0.011
## [1] "USDCAD15"
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## -0.053 -0.027 0.019 0.012 0.016 0.013 -0.015 0.045 -0.006 -0.026
## 11 12 13 14 15 16 17 18 19 20
## -0.012 0.031 -0.003 0.037 0.046 0.006 0.022 -0.016 -0.022 0.002
## [1] "USDCAD30"
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## -0.072 0.036 0.008 0.008 -0.008 0.035 0.041 0.021 0.022 -0.033
## 11 12 13 14 15 16 17 18 19 20
## 0.028 -0.043 -0.015 -0.003 0.000 0.002 -0.002 0.016 -0.022 0.013
## [1] "USDCAD60"
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## -0.049 0.030 -0.001 -0.010 -0.006 -0.085 0.008 -0.014 0.005 -0.012
## 11 12 13 14 15 16 17 18 19 20
## 0.027 -0.015 0.060 -0.019 -0.008 0.029 0.021 0.017 -0.034 -0.063
## [1] "USDCAD240"
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## -0.031 0.016 -0.007 0.038 -0.065 0.006 -0.026 0.038 -0.087 -0.018
## 11 12 13 14 15 16 17 18 19 20
## 0.022 -0.037 0.038 -0.035 0.014 -0.023 0.037 -0.032 -0.001 -0.028
## [1] "USDCAD1440"
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## -0.016 -0.040 -0.037 -0.031 -0.003 0.088 -0.025 0.053 -0.020 -0.064
## 11 12 13 14 15 16 17 18 19 20
## 0.022 0.026 -0.022 0.054 -0.030 -0.002 0.096 -0.013 0.016 0.082
## [1] "USDCAD10080"
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## -0.055 0.023 0.002 0.146 -0.053 -0.112 0.005 0.014 -0.076 0.033
## 11 12 13 14 15 16 17 18 19 20
## 0.015 0.086 -0.198 -0.019 0.003 -0.013 -0.020 -0.044 0.142 -0.015
## [1] "USDCAD43200"
par(mfcol = c(5, 2), las = 2, mar = c(2.1, 5.1, 2.1, 2.1))
ForexAcfPlot("XAUUSD")
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## -0.032 -0.002 0.059 -0.056 0.011 -0.007 -0.006 -0.005 -0.009 -0.019
## 11 12 13 14 15 16 17 18 19 20
## 0.018 -0.007 -0.001 -0.057 0.001 -0.013 -0.007 -0.003 0.002 0.057
## [1] "XAUUSD1"
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## 0.008 -0.033 -0.008 0.023 0.027 -0.003 -0.029 0.035 0.007 -0.003
## 11 12 13 14 15 16 17 18 19 20
## -0.006 0.020 -0.030 -0.049 -0.016 -0.021 0.036 0.037 -0.065 0.049
## [1] "XAUUSD5"
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## 0.011 0.005 0.004 -0.003 -0.014 0.005 0.007 0.014 -0.005 0.019
## 11 12 13 14 15 16 17 18 19 20
## -0.019 -0.011 -0.014 0.002 0.002 0.013 0.004 0.005 -0.009 0.007
## [1] "XAUUSD15"
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## 0.016 -0.031 0.022 0.023 -0.029 -0.032 -0.009 0.029 -0.003 0.021
## 11 12 13 14 15 16 17 18 19 20
## -0.020 0.009 0.003 0.019 0.017 -0.002 0.002 0.003 -0.020 0.006
## [1] "XAUUSD30"
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## 0.026 -0.015 -0.004 0.002 0.011 -0.020 0.014 0.022 -0.025 -0.006
## 11 12 13 14 15 16 17 18 19 20
## 0.031 -0.001 -0.003 0.037 -0.020 -0.003 0.013 0.024 0.023 -0.007
## [1] "XAUUSD60"
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## -0.004 -0.019 0.025 0.060 0.037 -0.038 -0.051 -0.050 -0.008 0.016
## 11 12 13 14 15 16 17 18 19 20
## 0.053 -0.005 -0.023 -0.001 0.018 -0.037 0.035 -0.001 0.010 -0.082
## [1] "XAUUSD240"
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## -0.002 -0.018 0.006 0.030 -0.002 -0.064 -0.021 0.000 0.008 0.018
## 11 12 13 14 15 16 17 18 19 20
## -0.019 -0.022 0.020 0.018 -0.001 -0.024 0.027 0.019 -0.035 0.010
## [1] "XAUUSD1440"
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## -0.010 -0.022 -0.013 0.006 -0.086 -0.069 -0.014 -0.012 -0.027 -0.026
## 11 12 13 14 15 16 17 18 19 20
## 0.013 0.061 0.060 -0.038 -0.020 0.035 -0.011 -0.005 0.026 -0.041
## [1] "XAUUSD10080"
##
## Autocorrelations of series 'retDataMat[, "Close"]', by lag
##
## 1 2 3 4 5 6 7 8 9 10
## -0.152 -0.061 0.070 -0.057 0.054 0.029 -0.019 0.043 -0.072 0.103
## 11 12 13 14 15 16 17 18 19 20
## 0.090 0.038 -0.114 0.026 0.066 0.010 0.120 -0.073 -0.008 0.028
## [1] "XAUUSD43200"
#
# |------------------------------------------------------------------------------------------|
# | E N D O F S C R I P T |
# |------------------------------------------------------------------------------------------|