Hi Stephan,
It's a great article although I need to study it more in detail as I have not used Fourier Transforms for 60 years. I'm surprised there have not been other comments. Can you post the the expert mq5 source so the three options can be compiled into the expert and tested.
Thanks,
CapeCoddah
Hi,
Good article. Interesting idea. Sample mq5 code to test/try these options will be great. Thanks.
Hello
Experts used in articles are compiled via MQL5 wizard, so the rest of source code is already on your PC if you have metatrader.
Hi Stephan
i left my most loved math part (Fourier) for 30 year. So it is impossible to comment but i read your wonderful ''exercise".
Sorry that i cant help u, but thank u for share it
Stephan
Thanks for the reference, I will proceed to use it and let you know my results,
CapeCoddah
Hi Stephen,
very interesting article!
One hint to that: The parameters "Points" and "Epicycles" have to be deleted in the "Description of the class", they are not used in the code and the compiler complains after compiling the generated EA.
My Question: The EA is running smooth, but I can not reproduce your results in any way, maybe I did something wrong. Would you post the *.set file or even the EA source you generated?
Did you make a forward test?
Anyway it is a good lesson in using the FFT. Thank you!
I understand that the author did not even study the Fast Fourier Transform :) That's right, why bother, FT and FFT are empty and do not give anything in trading. I used to do these transformations 15 years ago in Matlab, and then I did the inverse transformation into time form - complete nonsense. FFTs are good in other fields, for example radar.
But wavelets are much more interesting. If you cut out all the high-frequency bands and do the inverse transformation to time domain, you will get an excellent low-pass filter without delays. However, it can be done much easier - through 2-pass filters.....
Hi,
it give me 12 errors
double CTrailingFT::ProcessFT(int Index) { double _ft = 0.0; static double _a[6]; // Fixed-size array al_complex _f[5]; // 5 epicycles // Populate _a with price differences for(int p=0; p<6; p++) { _a[p] = m_close.GetData(Index+p) - m_close.GetData(Index+p+1); } // Replace Alglib FFT with a custom 6-point FFT CustomFFT6(_a, _f); // Hypothetical optimized function // Compute _ft using dominant frequency (e.g., largest magnitude) double maxMagnitude = 0.0; for(int s=0; s<5; s++) { double mag = MathSqrt(_f[s].re*_f[s].re + _f[s].im*_f[s].im); if(mag > maxMagnitude) { maxMagnitude = mag; _ft = _f[s].re; // Or use a weighted combination } } return _ft * 100.0; // Adjust scaling as needed }
Replace Alglib with Custom FFT:
-
Alglib’s FFT may be slower for small datasets. Implement a lightweight FFT tailored to your window size (6 points).
Precompute MathExp(-2.0*M_PI*...) terms to avoid recalculating them on every tick.
Error Handling:
Add checks to prevent division by zero in _f[s].im / _f[s].re.Avoid matrix operations in ProcessFT() . Directly compute the required value for _ft using dominant frequencies.
Error Handling:
-
Add checks to prevent division by zero in _f[s].im / _f[s].re .
There are already much more efficient methods that use an elementary structure (M-shape). A change in its parameters gives a complete picture of changes in price dynamics (this is the impulse equilibrium theory).
As for the Fourier transform, in my opinion, it is a "drawn-out" method for financial markets, since the price movement of financial instruments is a non-stationary process, and analysing such processes with the help of Fourier methods is inefficient.
As for wavelet analysis, it is indeed more interesting, as various wave-like structures are used. However, this is only a kind of subjective selection of standards instead of using a single elementary structure, which is revealed in the theory of impulse equilibrium.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
New article MQL5 Wizard techniques you should know (Part 06): Fourier Transform has been published:
The Fourier transform introduced by Joseph Fourier is a means of deconstructing complex data wave points into simple constituent waves. This feature could be resourceful to traders and this article takes a look at that.
On compilation with the inbuilt RSI signal class and inbuilt fixed-margin money management, we do get these results for: EURJPY over the period: 2022.01.01 to 2023.01.01 on the timeframe: 4-hours. In running this test, we do not set profit targets nor use the default stop loss setting, therefore both inputs for these are zero. We want exits to be entirely determined by reversal of signal or triggering of the stop loss set by our trailing stop.
Author: Stephen Njuki