Difference calculus, examples. - page 5

 
Aleksey Panfilov:

As for Fourier, the topic is rich. If there is interest, we will touch it from time to time.

Most likely, the main questions will arise with the formulation of the problem (due to a different method). Now, as far as I understand, the indicator selects the most amplitude frequencies from the Fourier spectrum.

I had an idea to bolt theFourier indicator to an already averaged polynomial line. There is a suspicion that its extrapolated readings will change more slowly.


You are thinking in the right direction.

Extrapolations by polynomial and Fourier methods are completely different in nature. Fourier extrapolation can be applied only to the flat market due to its periodic nature (this line is a sum of sinusoids of different frequency, phase and amplitude), and it always tends to return back.

Whereas polynomial extrapolation, on the contrary, is good for trending because it keeps trying to "fly" down or up due to its stepwise nature.
That is why it makes a lot of sense to combine these two methods. Of course, we cannot simply add up the two methods. But I have a clear idea of how best to combine them, and it must be done using pattern recognition. And I already have some serious developments on this topic. I even published my first recognition algorithm quite a long time ago in the open source code. This algorithm finds linear (polynomial of degree 1) channels in all TFs. Despite the fact that it is the most primitive and slowest of my algorithm, I haven't found a better one even on the Market (I'm bragging ).

Fourier extrapolation is much slower than polynomial extrapolation, so it would be great to try to speed it up.

 
Evgeny Belyaev:

That's what everyone was doing... wrote...


To start a series of comparisons, let's return to what is well known.

 
      a1_Buffer[i] =iMA(NULL,0,145,0,MODE_EMA,PRICE_OPEN,i);// a1_Buffer[i]=  ((open[i] - Znach)    +5061600*a1_Buffer[i+1 ]-7489800   *a1_Buffer[i+2 ]+4926624*a1_Buffer[i+3 ]-1215450*a1_Buffer[i+4 ])/1282975;

      a5_Buffer[i+92]=a1_Buffer[i];   if(i<=1) { for(z=92-1;z>=0;z--){        a5_Buffer[i+0+z]=  2*a5_Buffer[i+1+z]  -  1*a5_Buffer[i+2+z]  ;  }}



      a2_Buffer[i]= ( (open[i] - Znach)  + 72   *a2_Buffer[i+1 ] )/73;
      
      a6_Buffer[i+92]=a2_Buffer[i];   if(i<=1) { for(z=92-1;z>=0;z--){         a6_Buffer[i+0+z]=  2*a6_Buffer[i+1+z] -  1*a6_Buffer[i+2+z]  ;  }}

The first linea1_Buffer isplotted as a classical EMA with a period of 145 (72*2+1), based on the opening points and shifted by 72 steps to the left. The wide gray line in the picture.

The second linea5_Buffer shows extrapolation using a straight line on the last two points of the first line. The gray line is thinner in the picture.

The third linea2_Buffer is constructed directly from the difference equation of the first degree.The blue line in the figure.

1*Y_(-1)-2*Y_0+1*Y_(+1)=0 First-degree difference equation for equally spaced points.

2*Y_(-1)-3*Y_0+1*Y_(+2)=0 First-degree difference equation for the shoulder in 2 intervals.

72*Y_(-1)-73*Y_0+1*Y_(+72)=0 First degree difference equation for the shoulder in 72 intervals.

This is essentially a first-degree Archimedes Lever equation.

The fourth linea6_Buffer shows extrapolation using a straight line from the last two points of the third line. The red line in the picture which is based on the opening point.

We can see the complete identity of the two constructions. I have given an example in order not to show the transformation of the code and the form of the classical EMA formula to the difference form.

I want to note that means, within the established terminology, we can call the construction using polynomials, EMA of a certain degree. Since the question of naming the constructed lines remains open. )

If you do not mind, of course:))

 
Nikolai Semko:

I even published my first recognition algorithm quite a long time ago in open source. This algorithm finds linear (polynomial of degree 1) channels in all TFs. Despite the fact that it is the most primitive and slowest of my algorithms, I haven't found a better one even on the Market(I'm boasting at).

In my opinion, quite justified. :))
 

I want to point out that the point can be extrapolated either by calculating the coefficients beforehand(a2_Buffer blue line), or by taking the desired value from the redrawn line(a6_Buffer yellow line). Although, of course, the second option is resource-consuming.

      a1_Buffer[i] =iMA(NULL,0,145,0,MODE_EMA,PRICE_OPEN,i);// a1_Buffer[i]=  ((open[i] - Znach)    +5061600*a1_Buffer[i+1 ]-7489800   *a1_Buffer[i+2 ]+4926624*a1_Buffer[i+3 ]-1215450*a1_Buffer[i+4 ])/1282975;

      a5_Buffer[i+92]=a1_Buffer[i];   if(i<=1100) { for(z=92-1;z>=0;z--){        a5_Buffer[i+0+z]=  2*a5_Buffer[i+1+z]  -  1*a5_Buffer[i+2+z]  ;  }}



      a2_Buffer[i]= 37* a1_Buffer[i] -36 *a1_Buffer[i+1];
      
      a6_Buffer[i+56]=a5_Buffer[i+56];  


 

Now averaging by polynomial of the second degree (EMA of the second degree) and extrapolation to different leverage with a straight line.

      a1_Buffer[i]=  ((open[i] - Znach)    +5328*a1_Buffer[i+1 ]-   2628 *a1_Buffer[i+2 ])/2701;

      a5_Buffer[i+92]=a1_Buffer[i];   if(i<=1100) { for(z=92-1;z>=0;z--){        a5_Buffer[i+0+z]=  2*a5_Buffer[i+1+z]  -  1*a5_Buffer[i+2+z]  ;  }}



      a2_Buffer[i+20]=a5_Buffer[i+20]; 
      
      a3_Buffer[i+38]=a5_Buffer[i+38]; 
      
      a4_Buffer[i+56]=a5_Buffer[i+56];
        
      a6_Buffer[i+74]=a5_Buffer[i+74];
    

The first figure is a construction scheme, in the second figure all lines that are not redrawn are drawn to the last value.

The indicators in the basement differ only in the specified line shift.



 

Averaging by polynomial of the second degree (EMA of the second degree) and extrapolation to different leverage with a square parabola (polynomial of the second degree).

      a1_Buffer[i]=  ((open[i] - Znach)    +5328*a1_Buffer[i+1 ]-   2628 *a1_Buffer[i+2 ])/2701;

      a5_Buffer[i+92]=a1_Buffer[i];   if(i<=1100) { for(z=92-1;z>=0;z--){        a5_Buffer[i+0+z]=  3*a5_Buffer[i+1+z]  -  3*a5_Buffer[i+2+z]  +  1*a5_Buffer[i+3+z]  ;  }}


      a2_Buffer[i+20]=a5_Buffer[i+20]; 
      
      a3_Buffer[i+38]=a5_Buffer[i+38]; 
      
      a4_Buffer[i+56]=a5_Buffer[i+56];
        
      a6_Buffer[i+74]=a5_Buffer[i+74];
  

The first figure is a construction scheme, in the second figure all linesthat are not redrawn are drawn to the last value.

The indicators in the basement differ only in the specified offset of the lines.


 

I've looked through the thread several times, and I don't understand: what are we talking about?

A quote is a random process, which can be approximated by a variety of analytical curves, in particular those that are here in the branch.

But there is one very fundamental point.

The coefficients in these analytical curves are constants, which is a very bold idea.

Since we approximate a random process, the coefficients are also RARE quantities and they should be EVALUATED rather than calculated, with all that implies. For example, one can easily get the value of a coefficient, see its value, and when looking at its evaluation, see that the error in determining the value of the coefficient is a multiple of that value itself.

And the trouble does not end there. An error is an error if it is distributed normally, and if it is NOT stationary, there is no coefficient at all, even though we see it.

This is why all indicators turn out to be non-functional. They can be indescribably beautiful, though.


PS.

There was a post above that the future does not flow from the past. So above is a disclosure of this sad fact.

 
SanSanych Fomenko:

I've looked through the thread several times, and I don't understand: what are we talking about?

A quote is a random process, which can be approximated by a variety of analytical curves, in particular those that are here in the branch.

But there is one very fundamental point.

The coefficients in these analytical curves are constants, which is a very bold idea.

Since we approximate a random process, the coefficients are also RARE quantities and they should be EVALUATED rather than calculated, with all that implies. For example, one can easily get the value of a coefficient, see its value, and when looking at its evaluation, see that the error in determining the value of the coefficient is a multiple of that value itself.

And the trouble does not end there. An error is an error if it is distributed normally, and if it is NOT stationary, there is no coefficient at all, even though we see it.

This is why all indicators turn out to be non-functional. They can be indescribably beautiful, though.


PS.

There was a post above that the future does not flow from the past. So above is a disclosure of this sad fact.

Thanks for your post.

Also remembered:

Forum on Trading, Automated Trading Systems and Testing Trading Strategies

Do you know how to prepare channels?

SanSanych Fomenko, 2017.12.31 11:00

Forum on trading, automated trading systems and testing trading strategies

Do you know how to prepare channels?

Aleksey Ivanov, 2017.12.31 10:48

Yes, I forgot to specify that I built these moving probability distributions non-delayed(moving averages built by 2n+1 points are lagging by n points, the same, of course, is true for distributions), for which just by the model

GARCH predicted a number of points creating a model of non-delayed distribution at the end part of history (which is important). My question to SanSanych(SanSanych Fomenko): "This approach will be more correct for jumps or will it also fail?


I cannot evaluate your method and give an answer.

You are trying to consider some idea, of which there are countless on the market, but like an overwhelming number of authors of ideas, you do not ask yourself a question: on what basis will everything that you see in the historical data be repeated in the future? Or more precisely: does your idea has at least a predictive ability?

The authors of GARCH didn't come to this model right away, in a fierce struggle with the ideologists of the efficient market, which they understood as stationary.

We know from statistics that the stationary processes can be predicted, and non-stationary ones are extremely poorly predicted. This is exactly the problem. Non-stationarity has rendered useless mountains of mathematics extremely effective in other fields.

GARCH Ideology:

  • The underlying premise is NOT stationarity.
  • formulate precisely the meaning of the word non-stationarity
  • start to go from NOT to stationarity to stationarity bit by bit.
  • The closer the stationarity, the greater the ability to predict the future the algorithm has


Does your idea go this way?


I think it will definitely come in handy.
 

Averaging by fourth-degree polynomial with leverage 72 (fourth-degree EMA) and extrapolation to different leverage using a straight line.

      a1_Buffer[i]=((open[i] - Znach)    +5061600*a1_Buffer[i+1 ]-7489800    *a1_Buffer[i+2 ]+4926624*a1_Buffer[i+3 ]-1215450*a1_Buffer[i+4 ])/1282975;

      a5_Buffer[i+92]=a1_Buffer[i];   if(i<=1100) { for(z=92-1;z>=0;z--){        a5_Buffer[i+0+z]=  2*a5_Buffer[i+1+z]  -  1*a5_Buffer[i+2+z]  +  0*a5_Buffer[i+3+z]  ;  }}


      a2_Buffer[i+20]=a5_Buffer[i+20]; 
      
      a3_Buffer[i+38]=a5_Buffer[i+38]; 
      
      a4_Buffer[i+56]=a5_Buffer[i+56];
        
      a6_Buffer[i+74]=a5_Buffer[i+74];
 

The first figure is a construction scheme, in the second figure all linesthat are not redrawn are drawn to the last value.

The indicators in the basement differ only in the specified line shift.


 

Averaging by fourth-degree polynomial with arm 72 (fourth-degree EMA) andextrapolation to different arms usinga square parabola (second-degree polynomial).

      a1_Buffer[i]=((open[i] - Znach)    +5061600*a1_Buffer[i+1 ]-7489800    *a1_Buffer[i+2 ]+4926624*a1_Buffer[i+3 ]-1215450*a1_Buffer[i+4 ])/1282975;

      a5_Buffer[i+92]=a1_Buffer[i];   if(i<=1100) { for(z=92-1;z>=0;z--){        a5_Buffer[i+0+z]=  3*a5_Buffer[i+1+z]  -  3*a5_Buffer[i+2+z]  +  1*a5_Buffer[i+3+z]  ;  }}


      a2_Buffer[i+20]=a5_Buffer[i+20]; 
      
      a3_Buffer[i+38]=a5_Buffer[i+38]; 
      
      a4_Buffer[i+56]=a5_Buffer[i+56];
        
      a6_Buffer[i+74]=a5_Buffer[i+74];

The first figure is a construction scheme, in the second figure all linesthat are not redrawn are drawn to the last value.

The indicators in the basement differ only in the specified offset of the lines.