Fast Fourier Transform - Cycle Extraction - page 99

 
mladen:
This is a correct version : fatl_correct.mq4

Hi mladen, can you to make mt5 version to this indicator.

https://c.mql5.com/forextsd/forum/138/fatl.gif

Thanks

 
karl17:
Hi mladen, can you to make mt5 version to this indicator.

https://c.mql5.com/forextsd/forum/138/fatl.gif

Thanks

Here is a metatrader 5 version : fatl.mq5

Files:
fatl.gif  65 kb
fatl.mq5  44 kb
 
mladen:
Here is a metatrader 5 version : fatl.mq5

thanks you again mladen.

 

We should be putting in a cycle low on EURUSD within the next couple of weeks. Based on the weekly chart, there is a stable 80 week cycle that matches closely with the 80 week cycle between 05/2007 and 11/2008 (0.89 correlation coefficient).

There has been a strong reversal the last two times the 80 week cycle target level low was penetrated. This would not be a bad level to scale out of shorts.

Good trading to everyone.

Alex

Files:
 

Anybody has this type of FFT for tradestation?

 
sebastianK:
Anybody has this type of FFT for tradestation?

All that I could find for tradestation are commercial versions (starting prices from $250)

 
mladen:
All that I could find for tradestation are commercial versions (starting prices from $250)

If you find a free one, please let us know

 
Batchboy:
UltraBanker,

Which method # 1-6 in ExtrapolatorEX is this method by Asian scientist please?

Thank you,

Truly,

Jerry

Sorry for the delay in response (please see my explanation above).

In spectra extraction there are TWO MAIN STEPS:

(1). Extraction the frequencies (tones).

(2). Fit amplitudes of them into the original signal.

Step (2) usually is provided by so-called Least Squares Method (LSQ) invented by Karl Gauss.

It is very accurate, but LSQ requires the solution of matrix linear equation.

In on-line (price quotes, or backtesting, or stepback optimization) or better say in-stream process - the linear matrix solution is somewhere SLOW.

Amplitude FIT method, proposed earlier by an asian scientist is FAST and still accurate.

The author of MQL4's Extrapolator (Vladimir, aka GPWR on MQL4 forum) re-invented it by another way and has made it slightly more general.

Do not mess AMPLITUDES FIT method from Step (2) with much more difficult FREQUENCY FIT or frequency extraction methods (scientifically called "frequency estimation" methods) from Step (1).

 
nevar:
UltraBanker,

Is this the amplitude-frequency fit part?

case 1: //Fit trigomometric series

double w,m,c,s;

for(int harm=0;harm<HarmNo;harm++)

{

Freq(w,m,c,s);

for(i=0;i<np;i++)

{

pv+=m+c*MathCos(w*i)+s*MathSin(w*i);

if(i<=nf) fv+=m+c*MathCos(w*i)-s*MathSin(w*i);

}

}

break;

O-o-o-o-ps!

Sorry, a whole year passed, and I did not respond. (I was VERY busy, writing world's first public EA with CUDA acceleration support.)

No, that was sequential spectra component (frequency tone) extraction. The fit method was:

//+-------------------------------------------------------------------------+

void Fit (double x[], double w, double& m, double& c, double& s)

{ double Sc = 0.0;

double Ss = 0.0;

double Scc = 0.0;

double Sss = 0.0;

double Scs = 0.0;

double Sx = 0.0;

double Sxc = 0.0;

double Sxs = 0.0;

for (int i = 0; i < np; i++)

{ double cos = MathCos (w * i);

double sin = MathSin (w * i);

Sc += cos;

Ss += sin;

Scc += cos * cos;

Sss += sin * sin;

Scs += cos * sin;

Sx += (x - pv);

Sxc += (x - pv) * cos;

Sxs += (x - pv) * sin;

}

Sc /= np;

Ss /= np;

Scc /= np;

Sss /= np;

Scs /= np;

Sx /= np;

Sxc /= np;

Sxs /= np;

if (w == 0.0)

{ m = Sx;

c = 0.0;

s = 0.0;

}

else

{ //calculating c, s, and m

double den = MathPow (Scs - Sc * Ss, 2) - (Scc - Sc * Sc) * (Sss - Ss * Ss);

c = ( (Sxs - Sx * Ss) * (Scs - Sc * Ss) - (Sxc - Sx * Sc) * (Sss - Ss * Ss)) / den;

s = ( (Sxc - Sx * Sc) * (Scs - Sc * Ss) - (Sxs - Sx * Ss) * (Scc - Sc * Sc)) / den;

m = Sx - c * Sc - s * Ss;

}

return;

}

//---------------------------------------------------------------------------------------------

I formatted the text in commentaries to his article in russian section:

https://www.mql5.com/ru/code/8732

Later in order to avoid loss of his priority I asked the author of extrapolator to publish his FIT method on the forum, and he did it:

1-я и 2-я производная от MACD - MQL4 форум

That was an extract from his UNPUBLISHED book on DSP.

 
mladen:
Just a question : why not using the FFT itself (that is available at this thread too) for cycles/frequencies/amplitudes extraction/calculation?

Because there are MANY major problems with "cycles theory" and it's implementation for real life's signals, ESPECIALLY for "signals", represented as price quotes.

Permit me to enlighten You and save a couple of your life's years:

First BAD NEWS:

(1). Cycle extraction is not an easy task. It is difficult for MANY reasons. The main reason is theory. Fourier theory simply does not work for non-stationary signals (real life's signals like music, voice, price quotings stream).

(2). Let me recommend to you gentlemen to stay away from implementation of that "theory of digital sampling". There are a couple of fundamental theorems in serious math, described in russian math articles and russian math books ONLY, and absolutely unknown to the western world. Forget about "sampling theorem" - it is simply not correct.

(3). The only person who did it almost right was James Simons from RenTec.

Let me re-post from another trading forum:

" I can explain their algo secret generally. Unfortunatelly, this will be VERY general explanation, it will probably not help You with Your own trading system. Sorry, dont ask me for more. I am not RenTec empl, never been.

Here the "secret":

1). RenTec is not predicting the price. Price is too random for their algos. They predict the prediction of price. They trade futures. The futures price is the result of numerous decisions made by a number of humans, using their "visions" AND usual trading tools: Moving Averages etc.

2). Visions of all traders and money managers on Wall Street are "analogous". They are smooth like a sound of music. Therefore the futures are more smooth than regular direct (random) prices.

3). Trading tools on Wall Street are deep "analogous" too, they are too much like digital filters.

4). Therefore, while RenTec cannot predict direct random price, they CAN predict the futures (semi-analogous "signal") - by using very special spectral DSP methods. Additionally, futures allow them to leverage.

5). I suggest nobody in RenTec holds the whole picture of algos' chain, except Simons.

5). The two main problems with spectral DSP are:

(a) modern methods can not exctract spectrum from a "signal" (the price) correctly,

(b) modern DSP methods can not predict the dance (the change) of price spectrum correctly,

and

(c) advanced methods by RenTec are unusual and VERY computing-power hungry for the real mode operations.

6). For the solution of (5b) RenTec hired specialists on speech recognition from IBM.

7). For the solution of (5a) they use very exotic DSP methods from VERY distant (from Wall Street) area of science. I think they started from the Simons' job at crypto, because they had to CHECK crypto long ago by some de-crypto methods. Simons does not use crypto, he started from the use of de-crypto technique, developed earlier for the avaluation of crypto power. He first has "decrypted" the price timeseries. Now they use algos from physics, and then if physics algos fail they use old de-crypto algos.

8). For the solution of (5c) they built the best in industry IT dept.

9). All above is almost useless without very special trick needed to DSP-ing processing of price timeseries. It is not described in books. I dont know how they do it. Maybe they dont use it at all - that is why we can see drawdowns in their returns, when the markets gone totally random."

Bad news (4) I have no intention and I will not dig deeply into it here. You have to have Simons' scientists level to implement "cycle extraction" correctly. Do not take it personally.

Bad news (5). Forex's signals are the most RANDOM among all type of price quotings.

That is why the "cycle extraction" in forex prices' stream is the most difficult. That is why retail forex brokers are beleiving that most of novice forex traders will fail by ANY trading method or combination of trading methods, otherwise profitable in other trading areas: futures, options etc.

Now THE GOOD NEWs:

1). You dont have to do it. We are starting developing it TODAY. Just wait.

2). Are there "cycles" in the forex prices ? - YES.

3). Is it difficult to get them? - YES. The signals are very short, which makes them almost impossible to extract by any of the modern math methods.

4). Are there "noise over signal" in forex? - YES, the "signal" in forex is noised, and, as much more important, CHOPPED by strong noise. We exactly know that after several years of development of our trend following Expert Advisor.

5). How does RenTec and Simons do it? - We know almost exactly how, and even why they did it - because one of the methods of cryptography from it's early beginning was to determine "are there the cycles in random data" or in output of random number generator.

6). We expect to get results in 1-2 years. We already got it 60 percent done. One of the main problem was the huge processing power required for the extremely extensive numeric calculations for the "cycles extraction". That is why RenTec first developed their biggest IT dept in industry.

7). Now this is not a problem: CUDA or OpenCL acceleration on GPU can solve it "on the trading desk". We successfully done it for our robust trend detection.

Sorry, I can not be more specific on math methods.

Reason: