Random Flow Theory and FOREX - page 17

 

Here's the AKF, take a look at it. Just need to be sure it counts correctly. Check it out.

Files:
akf_01.mq4  7 kb
 
Prival:

Here's the AKF, take a look at it. Just need to be sure it counts correctly. Check it out.


The ACF calculation itself is done by definition and this is correct to begin with - the code is simple and transparent. But it would be interesting to compare the speed if calculated via FFT. By the way this code also lends itself to noticeable acceleration.
 
lna01:
Prival:

Here's the AKF, take a look at it. Just need to be sure it counts correctly. Check.


The ACF calculation itself is done by definition and this is correct to begin with - the code is simple and transparent. But it would be interesting to compare the speed if you calculate via FFT. By the way, this code also lends itself to noticeable acceleration.


Through FFT will not be exact, on 8th page chart ('Random Flow Theory and FOREX'), red line ACF by formula, blue curve is symmetric about the centre. I may have done something wrong, though (the file itself is attached on the same page above). lna01 Can you tell me how to build ACF correctly using FFT, I did it from memory, maybe I made a mistake.

forward FFT -> modulus+ ^2 -> reverse FFT -> extraction of the real part Re() -> normalization

 
Prival:

Here's the AKF, take a look at it. Just need to be sure it counts correctly. Check it out.

Didn't you compare it with matcad? I specially made WriteToFile to check ;)
 
lna01:
But it would be interesting to compare the speed if counting via FFT.
In the first variant there was also method via FFT - it is really several orders of magnitude faster. It was abandoned because of questionable accuracy.

lna01:
By the way, this code lends itself to noticeable acceleration as well.
I agree, the code can be optimized. But it's not a question of speed yet, so I don't want to do it.
 
2 Prival , komposter:

ACF via fft was symmetrical most likely due to underwriting zeros. And the accuracy is questionable for some reason.



But something seems to me that the realtime boosted head-on calculation should be faster than the fft version. However, the total estimated amount of calculations continues to be very confusing. In particular the arbitrariness in the choice of the linear regression length is already questionable at this stage. A similar problem for linear regression channels is still a problem by and large. In fact, I already wrote about it earlier in this thread.
 

Yes, there are more questions than answers. But it's getting interesting.

1. The correlation coefficient is not supposed to be modulo greater than 1, but it is.

2. Why a*x+b, Prival? Is that how you want to detrend the graph? There are other ways that are more accurate. For example, the linear regression (the analogue of mach, but it has a smaller lag). By deducting the current LR value from the price, we perfectly get rid of trends, including non-linear ones.

We can simply take the first price difference (i.e. form a series of returns), but that removes only linear components of trends. If we take the second difference, we also remove the quadratic ones, etc.

If you want to get rid of lag (but want to retrace on history), then you can do something like Fourier MA, i.e. based on Fourier transform and high frequencies rejection. Klot has this as well.

 
Mathemat:

1. The correlation coefficient is not supposed to be modulo greater than 1, but it is.

If we are talking about the picture with fft, then for some reason the first element drops out of the series, and it is it that is used for normalization. I did not try to figure out what it is from the images given in the post.
 
Be careful with FFT: tnn (or nl in the body) must be a power of two, i.e. 2^n, where n is an integer.
 
rsi:
You have to be more careful with FFT: tnn (or nl in the body) should be a degree of two, i.e. 2^n, where n is an integer.
In this sense all is OK, but I lost odd elements of spectral density :). So there is no problem with fft, I will replace source in that post now.


P.S. I removed wrong source code, and place it here.

P.P.S. Just in case more details about data handling: Size of original array needs to be increased 2 times, then again increase it to the nearest degree of two. All added cells should be written zeros. The array of spectral density for inverse fft should also have extended size; amplitude squares should be written to cells for real components, and (naturally) zeros should be written to cells for imaginary ones. As a result we take the elements from the beginning to the original size of the array.
2 Prival: I don't know how to reproduce this exactly in Matkadec, trial and error should help in the end. The ACF should match with reasonable accuracy.
Files:
akf_01_fft.mq4  13 kb