by robocod » Tue Feb 02, 2016 5:48 pm
I've found a bug with the mathex.correl() function.
This function used to work correctly, but since the update of Trading Station I have noticed that it is not working properly in some cases.
It's hard to pinpoint the problem, but here is a dump of some variables. The i & j values are indices into some forex data sources. So, it should be finding the correlation of each of these combinations of 4 streams.
Trace: 'i = 3, j = 4, correl = 0'
Trace: 'i = 2, j = 4, correl = 0.831378'
Trace: 'i = 2, j = 3, correl = -0.42464'
Trace: 'i = 1, j = 4, correl = 0'
Trace: 'i = 1, j = 3, correl = 0'
Trace: 'i = 1, j = 2, correl = -0.821594'
The "0" values are wrong. I checked this in Excel, for some of the streams
Correl(3,4) should be -0.245392393 (this was not correctly computed by mathex.correl() )
Correl(2,4) should be 0.831378106 (this was correctly computed by mathex.correl() )
Correl(1,4) should be -0.733895749 (this was not correctly computed by mathex.correl() )
Correl(1,3) should be 0.282875814 (this was not correctly computed by mathex.correl() )
Correl(1,2) should be -0.821593597 (this was correctly computed by mathex.correl() )
So, you see some are computed correctly, but others are 0 ! So, something went wrong with the computation.
I have written my own function to replace mathex.correl(), but clearly this needs investigating / fixing.
Furthermore, it raises the question about what else has been broken in the mathex library?