Discussing the article: "Implementation of the Augmented Dickey Fuller test in MQL5"

 

Check out the new article: Implementation of the Augmented Dickey Fuller test in MQL5.

In this article we demonstrate the implementation of the Augmented Dickey-Fuller test, and apply it to conduct cointegration tests using the Engle-Granger method.

Simply put an ADF test is a hypothesis test, that allows us to determine if a specific characteristic of the observed data is statistically significant. In this instance the characteristic being acertained is the stationarity of a series.  A statistical hypothesis is an assumption made about a data set that is represented by a sample. We can only know the real truth by working with the entire data set. Which is usually not possible for one reason or another. So a sample of a data set is tested to posit an assumption of the entire data set. The important point to remember here is that the truth of a statistical hypothesis is never known with certainty when working with samples. What we get is whether an assumption is likely true or false.

A non stationary series with a trend

In an ADF test we consider two scenarios:

  • The Null hypothesis that a unit root is present in the time series.
  • The Alternative hypothesis that the times series does not exhibit a unit root.

Author: Francis Dube

 
MetaQuotes:

Check out the new article: Implementation of the Augmented Dickey Fuller test in MQL5.

Author: Francis Dube

Hey, thanks a lot for this article. I used the code of this article but I would like to know if you ever updated this code for speed. i did a test but when the size gets above thousand it really takes time. I don’t know if it’s something that can be optimized.
 

Hello Francis,

I have read the article and tested the code which worked fine to me. In your article you defined:

Cointegration

Correlation and cointegration are statistical concepts used to measure relationships between variables, especially in the context of time series data. While both measure relationships, they serve different purposes and are applied in distinct scenarios. Correlation refers to the statistical measure of the strength and direction of the linear relationship between two variables.

and we know that correlation can be positive and negative.

My question here is can we also have cointegration which is also negative? In general your article covers the positive part.

How the code could be changed to cover the second case to have two symbols which are likely cointegrated but negatively i.e. when one of these symbols is growing up, its pair is falling down and vice versa with a level of confidence > 90%?

Thank you in advance.

 
Rumen Chikov #:

Hello, Francis,

I have read the article and tested the code which works fine. In your article you have defined:

And we know that correlation can be positive and negative.

My question is, can we also have cointegration which is also negative? Overall your article covers the positive part.

How can we modify the code to cover the second case to have two symbols that are probably cointegrated but negatively, i.e. when one of these symbols goes up, its pair goes down and vice versa with a confidence level > 90%?

Thanks in advance.

Replace all Ki values in one of the rows with 1/Ki.