You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
It's not a bad result if we make a backbone for the Fourier decomposition. In particular, we can easily extrapolate the regression forward and plot the Fourier relative to it. It is possible to fit a mouving as a support and plot the sum of harmonics, in a separate window, as if the mouving continues linearly. You can base it on a smoothly varying average, like T3, shifted by half a period backward, so that it exactly fits the data and extrapolate the end with a parabola, which is adjusted for minimum RMS, and relative to this extrapolation, build the Fourier. But in any case, there is a high probability of repeating cycles if we build several variants of the Fourier extrapolation with different periods and optimize each variant with respect to the minimum RMS. If there is a coincidence in the readings of several variants, they can be considered probable. If there is further advance or lag, this will produce a corrective difference signal that can be used for auto-tuning or recalculation. This is reminiscent of the FATF detector in radio receivers, which is the most efficient and immune to interference.
Well, actually it is not such a big problem to output the Fourier series without getting ahead in time, so that the end was close to the series. It is interesting to output the Fourier of future quotes. You have posted screenshots of your indicator plotting the Fourier series for the future time which coincides well with reality. On what principles does it work?
But more or less satisfactory results may be obtained if the minimum harmonic is 12 to 24 hours and minimum period of 2-3 days or more. This is for the daily forecast. For global forecast the technique is the same but periods are longer of course. Depending on the scale, long range monthly and yearly forecasts coincide very well with real data, especially on some frequencies, which periodically repeat with a very high degree of probability. In order to get statistics on these frequencies - a clever spectrum analyser is made, which can also be dragged across the entire time range.
The decomposition there is made relative to LinearRegressin. The tail is like a radio, to get the best audibility, it is desirable to tune for minimum noise and maximum signal, i.e. the tuning is done according to the minimum RMS. To easily change the period - a straight line or regression channel script is applied. The end data is captured and transmitted to the indicator. Thus, by moving the lines we instantly change the period and recalculate the whole picture. The comment shows the RMS and adjustments are made according to the minimum RMS plus a small shift by eye to make highs and lows coincide as much as possible. We also added ability to change number of harmonics through function GetAsyncKeyState(int nVirtKey), then by pressing appropriate arrows on the keyboard we can quickly add or subtract number of harmonics. The same is done by means of script, which draws it all. I've already written a little about settings and variants before. For different periods and different plausibility the number of harmonics is taken differently.
But more or less satisfactory results may be obtained if the minimum harmonic is 12 to 24 hours and minimum period of 2-3 days or more. This is for the daily forecast. For global forecast the technique is the same but periods are longer of course. Depending on the scale, long range monthly and yearly forecasts coincide very well with real data, especially on some frequencies, which periodically repeat with a very high degree of probability. In order to get statistics on these frequencies - a clever spectrum analyser is made, which can also be dragged across the entire time range.
I don't really understand this...
The Fourier series is built from the difference in price and the value of the regression line, right?
It's not very clear about the tail though.... What is the adjustment for the minimum RMS?
Thanks in advance for answers =)
I don't really understand...
A Fourier series is constructed from the difference in price and the value of the regression line, right?
It's not very clear about the tail, though.... What is the adjustment for the minimum RMS?
Thanks in advance for answers =)
Yes. First we calculate LR[i] coordinates. Then array dc[i]=Close[i]-LR[i]; From array dc[i] build Fourier fx[i]. And add LR[i] coordinates. fx[i]=fx[i]+LR[i] or fx[i]+=LR[i]; If we extrapolate, we calculate LR[i] and fx[i] before and after i=0 (you can pick it up yourself).
The "tail" is what is known from i=T to i=0; Since we can shift, shrink or stretch the estimation period (T) with the script, we automatically recalculate the "tail" RMS with each shift.
That is sq=0.0; for (int n=0; n<T; n++) sq+=(Close[i0+n]-fx[n])*(Close[i0+n]-fx[n]); sq=MathSqrt(sq/T); and set for minimum RMS (sq).
In my screenshots, the "tail" is shown in yellow and green, while the extrapolation is shown in red and blue.
Generally, at first all these constructions take a lot of time and mental effort, and if you feel you're not ready yet, wait until you mature. Otherwise, you may get tired of it all, and you will not be happy with the results.
Yes. First we calculate LR[i] coordinates. Then array dc[i]=Close[i]-LR[i]; From array dc[i] build Fourier fx[i]. And add LR[i] coordinates. fx[i]=fx[i]+LR[i] or fx[i]+=LR[i]; If we extrapolate, we calculate LR[i] and fx[i] before and after i=0 (you can pick it up yourself).
The "tail" is what is known from i=T to i=0; Since we can shift, shrink or stretch the estimation period (T) with the script, we automatically recalculate the "tail" RMS with each shift.
That is sq=0.0; for (int n=0; n<T; n++) sq+=(Close[i0+n]-fx[n])*(Close[i0+n]-fx[n]); sq=MathSqrt(sq/T); and set for minimum RMS (sq).
In my screenshots, the "tail" is shown in yellow and green, while the extrapolation is shown in red and blue.
In general, at the beginning all these constructions take a lot of time and if you feel that you're not ready yet, wait until you are mature enough. Otherwise you may get tired of it all, and the results you get will not be happy.
Or the number of harmonic frequencies in the Fourier decomposition is adjusted by minimum RMS?
However, the most interesting thing, namely how the extrapolation of the Fourier function is done, you still did not tell =)
So the minimum RMS is set to T, am I right?
Or the number of harmonic frequencies in the Fourier decomposition is adjusted by minimum RMS?
However, the most interesting thing is how the extrapolation of the Fourier function is done =)
As a result of Fourier calculation we will have number of harmonics N, coefficients ak[k],bk[k], where k corresponds to harmonic number (k=0. ..N); and formula for Fourier calculation sum=0.0; for(k=0; k<=N; k++) sum+=ak[k]*MathCos(w*k*i)+bk[k]*MathSin(w*k*i); fx[i]=sum;
Now if we want to extrapolate, say, half a period ahead, we calculate
data from T to -T/2; for(int i=T; i>=-T/2; i--), but because arrays must contain only positive indexes, we put what from -1 to -T/2 into the second array, or there is a trick to bypass division into 2 arrays by shifting all elements by +T/2 back, and this shift is considered while drawing. The rest of the description makes sense only if we already have experience in such constructions. In scripts, we have no problems at all with drawing forward. In indicators, we should use SetIndexShift( );
That is, you calculate fx[i] at i<0 by formula:
sum=0.0; for(k=0; k<=N; k++) sum+=ak[k]*MathCos(w*k*i)+bk[k]*MathSin(w*k*i); fx[i]=sum;
Like this?
And you build the Fourier function for what period? [T,0]?
That is, you calculate fx[i] at i<0 by formula:
sum=0.0; for(k=0; k<=N; k++) sum+=ak[k]*MathCos(w*k*i)+bk[k]*MathSin(w*k*i); fx[i]=sum;
Like this?
And you build the Fourier function for what period? [T,0]?
for (i=T; i>=-T/2; i--)
{
sum=0.0;
for(int k=0; k<=N; k++) sum+=ak[k]*MathCos(w*k*i)+bk[k]*MathSin(w*k*i);
fx[i+T/2]=sum+b+a*i;
}
How exactly are the coefficients ak, bk calculated?
Is the integral taken over what interval? From T to 0 or what?
How exactly are the coefficients ak, bk calculated?
Is the integral taken at what interval? From T to 0 or what?
for (int k=0; k<=N; k++)
{
sum_cos=0.0;
sum_sin=0.0;
for (int i=0; i<T; i++)
{
sum_cos+=(Close[i]-b-a*i)*MathCos(w*k*i);
sum_sin+=(Close[i]-b-a*i)*MathSin(w*k*i);
}
ak[k]=sum_cos*2/T;
bk[k]=sum_sin*2/T;
}
ak[0]=ak[0]/2;