Difference calculus, examples. - page 10

 
Aleksey Panfilov:

To see the dynamics.

The same Expert Advisor on M15.



Don't pay attention to the scolding words on this site: "overdrawing". Those indicators that make too many redraws have some predictive ability, while those that do not make too many redraws usually do not have any predictive ability. Predictive ability is not a subject for discussion here. In their essence your indicators are geared to predict (extrapolate) into the future and you can get something out of them.


For the pictures, the valuable in my opinion

I really like the previous green picture. The even green triangle indicates that there is a broad band, which corresponds to the parameters that will affect the future performance of your EA. The second picture doesn't reveal such an extremely valuable property of the Expert Advisor

 

The same expert on the M5. The story is shorter by about half.


Files:
2018_02_05.zip  219 kb
 
SanSanych Fomenko:

Don't pay attention to the scolding words on this site: "re-drawing". Those indicators which re-draw have at least some predictive ability, and those which don't usually have no predictive ability at all. Predictive ability is not a subject for discussion here. In their essence your indicators are geared to predict (extrapolate) into the future and you can get something out of them.


For the pictures, the valuable in my opinion

I really like the previous green picture. The even green triangle indicates that there is a broad band, which corresponds to the parameters that will affect the future performance of your EA. The second picture doesn't say anything about that extremely valuable property of your Expert Advisor

Thank you.

I agree with you. Apparently, on M30 and now on M5 the indicator synchronizes better with the price behavior.

And of course this is still an estimation, a very "rough" approach.

 

I would like to point out that the resource saving condition highlighted in yellow in the attached indicators is zeroed, so that the non-drawn line is displayed on the entire chart.

      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>=0) { for(z=92-1;z>=0;z--){        a5_Buffer[i+0+z]=  4*a5_Buffer[i+1+z]  -  6*a5_Buffer[i+2+z]  +  4*a5_Buffer[i+3+z]  - 1*a5_Buffer[i+4+z];  }}
      a2_Buffer[i+92-leverage]=a5_Buffer[i+92-leverage]; 

In testing, as far as I understand it, the zero bar is the last one drawn by the tester. Then it is reasonable to limit the number of fully computed bars during optimization to the last one.

      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<=0) { for(z=92-1;z>=0;z--){        a5_Buffer[i+0+z]=  4*a5_Buffer[i+1+z]  -  6*a5_Buffer[i+2+z]  +  4*a5_Buffer[i+3+z]  - 1*a5_Buffer[i+4+z];  }}
      a2_Buffer[i+92-leverage]=a5_Buffer[i+92-leverage]; 

Or a certain number of last ones.

      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<=1000) { for(z=92-1;z>=0;z--){        a5_Buffer[i+0+z]=  4*a5_Buffer[i+1+z]  -  6*a5_Buffer[i+2+z]  +  4*a5_Buffer[i+3+z]  - 1*a5_Buffer[i+4+z];  }}
      a2_Buffer[i+92-leverage]=a5_Buffer[i+92-leverage]; 

But in this case the indicator will not correspond to the calculated one during visualization on the entire chart.

 

I added the ability to select the degree of extrapolation to the indicator:

      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;

      if(line_power ==1)   {    a5_Buffer[i+92]=a1_Buffer[i];   if(i>=0) { for(z=92-1;z>=0;z--){        a5_Buffer[i+0+z]=  2*a5_Buffer[i+1+z]  -  1*a5_Buffer[i+2+z];  }}}
      if(line_power ==2)   {    a5_Buffer[i+92]=a1_Buffer[i];   if(i>=0) { 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];  }}}
      if(line_power ==3)   {    a5_Buffer[i+92]=a1_Buffer[i];   if(i>=0) { for(z=92-1;z>=0;z--){        a5_Buffer[i+0+z]=  4*a5_Buffer[i+1+z]  -  6*a5_Buffer[i+2+z]  +  4*a5_Buffer[i+3+z]  - 1*a5_Buffer[i+4+z];  }}}
      if(line_power ==4)   {    a5_Buffer[i+92]=a1_Buffer[i];   if(i>=0) { for(z=92-1;z>=0;z--){        a5_Buffer[i+0+z]=  5*a5_Buffer[i+1+z]  - 10*a5_Buffer[i+2+z]  +  10*a5_Buffer[i+3+z] - 5*a5_Buffer[i+4+z]  +  1*a5_Buffer[i+5+z];  }}}

      a2_Buffer[i+92-leverage]=a5_Buffer[i+92-leverage]; 
 

And accordingly in the Expert Advisor.

 ma_1=iCustom(NULL,0,"2018_02_08_EMA_Polynom_s4_s1_4_p72_v.2",line_1_power, leverage_1,300,3,0);
 ma_2=iCustom(NULL,0,"2018_02_08_EMA_Polynom_s4_s1_4_p72_v.2",line_2_power, leverage_2,300,3,0);
 ma_1_P=iCustom(NULL,0,"2018_02_08_EMA_Polynom_s4_s1_4_p72_v.2",line_1_power, leverage_1,300,3,1);
 ma_2_P=iCustom(NULL,0,"2018_02_08_EMA_Polynom_s4_s1_4_p72_v.2",line_2_power, leverage_2,300,3,1);
 

Optimization on the intersection of the line extrapolated by the polynomial of the fourth degree (with the leverage of extrapolation 72, this is the opening price of the bar), the line extrapolated by the polynomial of the third degree.


Files:
2018_02_08_2.zip  211 kb
 

I was browsing the thread and noticed that the comment from post 64 died undeservedly. ))

Dear moderators, can it be restored, in its former place in the appropriate context? Or open it for me to edit ? (Below, the comment itself)

Aleksey Panfilov2018.01.30 21:41RU
Aleksey Panfilov:

Yes.

Directly related to Newton's Binomial. And Pascal's triangle. Added 01/30/2018

It is true for equidistant points:

1*Y1-2*Y2+1*Y3=0 is the difference equation of the straight line.

1*Y1-3*Y2+3*Y3-1*Y4=0 - second degree parabola difference equation.

1*Y1-4*Y2+6*Y3-4*Y4+1*Y5=0 - difference equation of the parabola of the third degree.

It also overlaps with the topics:

https://www.mql5.com/ru/forum/61389/page48#comment_5633264

https://www.mql5.com/ru/forum/211220/page2#comment_5632736 .

1*Y1-5*Y2+10*Y3-10*Y4+5*Y5-1*Y6=0- difference equation of the fourth degree parabola.

1*Y1-6*Y2+15*Y3-20*Y4+15*Y5-6*Y6 +1*Y7=0- difference equation of the fifth degree parabola.

1*Y1-7*Y2+21*Y3-35*Y4+35*Y5-21*Y6 +7*Y7-1*Y8=0- difference equation of the sixth degree parabola.


Interpolation formulas with a shoulder of 1 interval are derived directly from the equations for equidistant points.

3*Y2=1*Y1+3*Y3-1*Y4 - interpolation by the parabola of the second degree.

4*Y2=1*Y1+6*Y3-4*Y4 +1*Y5- interpolation by parabola of the third power.

5*Y2=1*Y1+10*Y3-10*Y4+5*Y5-1*Y6- interpolation by the parabola of the fourth power.

6*Y2=1*Y1+15*Y3-20*Y4+15*Y5-6*Y6 +1*Y7- interpolation of the fifth degree parabola.

7*Y2=1*Y1+21*Y3-35*Y4+35*Y5-21*Y6 +7*Y7-1*Y8- interpolation by parabola of the sixth degree.

As a code:

 
      a1_Buffer[i]=(open[i]   +3*a1_Buffer[i+1 ]   -1*a1_Buffer[i+2 ]  )/3;
      a2_Buffer[i]=(open[i]   +6*a2_Buffer[i+1 ]   -4*a2_Buffer[i+2 ]   +1*a2_Buffer[i+3 ]  )/4;
      a3_Buffer[i]=(open[i]   +10*a3_Buffer[i+1 ]  -10*a3_Buffer[i+2 ]  +5*a3_Buffer[i+3 ]  -1*a3_Buffer[i+4 ])/5;
      a4_Buffer[i]=(open[i]   +15*a4_Buffer[i+1 ]  -20*a4_Buffer[i+2 ]  +15*a4_Buffer[i+3 ]  -6*a4_Buffer[i+4 ]  +1*a4_Buffer[i+5 ])/6;
      a5_Buffer[i]=(open[i]   +21*a5_Buffer[i+1 ]  -35*a5_Buffer[i+2 ]  +35*a5_Buffer[i+3 ]  -21*a5_Buffer[i+4 ]  +7*a5_Buffer[i+5 ]  -1*a5_Buffer[i+6 ])/7;

The figure shows the beginning of the graph.

It is clearly seen that the lines constructed by polynomials of degree 2-4 (gray, blue, green) steadily stay near the graph.

The lines constructed by polynomials of powers 5 and 6 (red, yellow) get into something similar to resonance or auto-oscillation, and gradually accumulate the amplitude. Increasing the shoulder for polynomials of degree 5 or greater does not change the situation.


Interpolation by the difference equation of a function composed ofthe sum of sinusoids of given periods allows to increase "as if the degree of the polynomial", for example to 12 degrees (this is like 6 sinusoids near the constant).

And at the same time, a similar situation(resonance) can also be encountered by interpolating a function of one sinusoid near a constant (analog of a second-degree polynomial), with a certain combination of shoulder and period.

The analogy with polynomials is carried out by the number of minimum required points.

 

Optimization of the indicatorNikolai SemkoBanzai.mq4 from message 57 of this thread.

Same Expert Advisor, optimized parameter is shift of the line to the right.

 ma_1=iCustom(NULL,0,"Banzai",leverage_1, 0,leverage_1);
 ma_2=iCustom(NULL,0,"Banzai",leverage_2, 0,leverage_2);
 ma_1_P=iCustom(NULL,0,"Banzai",leverage_1, 0,leverage_1+1);
 ma_2_P=iCustom(NULL,0,"Banzai",leverage_2, 0,leverage_2+1);

Results:


Files:
2018_02_09.zip  245 kb
 

Optimization of the indicatorNikolai SemkoBanzai.mq4 frommessage 57of this thread.

Same on M15:


Files:
2018_02_09_2.zip  212 kb
 

Most optimization graphs clearly show the boundary of the "reverse" signal (red line), and accordingly a certain "mirroring " of the results (example highlighted by the yellow line).