Correlations revisited ... - page 2

 

Statistical Arbitrage

Hi mladen,

very good thread ! Do you have a recommendation what correl type should be taken as filter for statistical arbitrage trading ? As far as I know the Pearson type is typically taken there.

By the way, a statistical arbitrage EA executing pair trades based on spread MA and using standard dev bands for hedge order opening and closing would be a good thread as well ...

 

Very interesting indeed.

One request: would love to see the USD Index added.

IMO, it would be an interesting study to compare any USD pair to the USD index that way, especially with the mutliple algorithms included in this gem.

Been looking at code, not sure how to add it myself.

USD Index = 50.14348112 * MathPow(eurusd,-0.576) * MathPow(usdjpy,0.136) * MathPow(gbpusd,-0.119) * MathPow(usdcad,0.091) * MathPow(usdsek,0.042) * MathPow(usdchf,0.036);

I think we may need another buffer, so perhaps drop one..?

Thanks in advance.

San.

 

Simple and elegant solution, very nice. Thanks.

San.

 
mladen:
Quite some time ago I was doing some work on Pearson correlation indicator. It was working OK and I thought that the "story", as far as coding is concerned, is finished. There is Pearson, there is Spearman's rank correlations...

Ops, lets go back a bit :

Reading about correlations it struck me that Pearson correlation and Spearman's rank correlation are constantly compared. First thought was : "Why in the hell are they comparing those when the have so little in common?". Oh well, As usual, first reaction was wrong. The problem needed to be solved and the "mystery" needs to be clarified. So here we go :

First a statement : Spearman's rank correlation that usually is used on metatrader platform is just one special case of Spearman's rank correlation, and due to its cause of being special, it can not even be called a correlation. It comes from a fact that it is a case when the "counter part" used for correlation is of a constant rank and is because of that removed from the equitation : when using time as a second array in "correlations" calculation, time always has a constant rank (since it always has unequal values (unequal by same value - the change in time) in ascending order) and because of that can be removed from calculation - so it is a "correlation" of price and its times

__________________________________

Now that is the conclusion that comes before the end : I decided to clarify the whole mambo jumbo about correlations and to add what normally is used in statistics for correlations interpretation and usage in trading. Here we will have 3 prevailing correlations methods covered and solved :
- Pearson(linear) correlation

- Spearman's rank correlation (it will be done in most detail)

- and Kendall's tau

I would be interested in the C++ source if you feel like sharing.

 

...

Here you go

dumbmoney:
I would be interested in the C++ source if you feel like sharing.
Files:
 

Cointegration

Was wondering if you have pursued any cointegration work?

 

Cointegration

adeo:
Was wondering if you have pursued any cointegration work?

Cointegration calc in Metatrader alone is not possible. Nevertheless there is an R integration with Metatrader done by the trader 7bit. R is covering various kinds of cointegration calculations, which can be called directly with mql4 using the 7bit R software.

 

...

Boxter:
Cointegration calc in Metatrader alone is not possible. Nevertheless there is an R integration with Metatrader done by the trader 7bit. R is covering various kinds of cointegration calculations, which can be called directly with mql4 using the 7bit R software.

Thank you for the link. I found 7bit and his efforts during my research. I also found Cointegration analysis using Johansen procedure. I contracted to have this turned into a dll (for all I know you are the developer . Anyone interested can PM me for more information. I'm now trying to understand the mathematics to better apply the tool. So far, nothing to report. Future plans are to investigate baskets > 2.

 

I am quite interested in the topic of correlations but not necessarily between different pairs. I'm curious how it would look if you applied Pearson or Spearman correlation to two moving averages of the same currency pair. Would it look just like the MACD or something different?

 
sothirsty:
I am quite interested in the topic of correlations but not necessarily between different pairs. I'm curious how it would look if you applied Pearson or Spearman correlation to two moving averages of the same currency pair. Would it look just like the MACD or something different?

I think that in that case maybe more interesting would be to use some correlation basis like the indicators from these posts : https://www.mql5.com/en/forum/general

Here is one made to show Pearson correlation of two moving averages of a length, price and type you chose. So, it does not look like a MACD but is an oscillator. The question is how to use it in trading since the correlation is to averages (how well one average correlates to another average) and what would be the criteria for trading decision we should use from this indicator

Reason: