差分微积分,例子。

 

我提议在这个线程中收集关于差分计算的指标和专家,在开放源代码中。

如果会有兴趣,我们最终会建立或绘制一些有用的东西。:)

我以一个更清晰的版本重写了这个指标 作为例子。

//|                                Copyright 2016, Aleksey Panfilov. |
//|                                                filpan1@yandex.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2018, Aleksei Panfilov. filpan1@yandex.ru"
#property link      "filpan1@yandex.ru"
#property version   "1.2"
#property description    "2018_01_10_Polynom_s4_s2_p72"
#property strict

#include <MovingAverages.mqh>


#property indicator_chart_window
#property indicator_buffers 6
#property indicator_plots   2
//--- plot a1_
#property indicator_label1  "MACD"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrSilver
#property indicator_style1  STYLE_SOLID
#property indicator_width1  2
//--- plot a2_
#property indicator_label2  "Signal"
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrRed
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1
//--- plot a3_
#property indicator_label3  "Fast_line_1"
#property indicator_type3   DRAW_LINE
#property indicator_color3  clrBlueViolet
#property indicator_style3  STYLE_SOLID
#property indicator_width3  6
//--- plot a4_
#property indicator_label4  "Fast_line_2"
#property indicator_type4   DRAW_LINE
#property indicator_color4  clrBlue
#property indicator_style4  STYLE_SOLID
#property indicator_width4  1
//--- plot a5_
#property indicator_label5  "Slow_line_1"
#property indicator_type5   DRAW_LINE
#property indicator_color5  clrDarkGreen
#property indicator_style5  STYLE_SOLID
#property indicator_width5  4
//--- plot a6_
#property indicator_label6  "Slow_line_2"
#property indicator_type6   DRAW_LINE
#property indicator_color6  clrRed
#property indicator_style6  STYLE_SOLID
#property indicator_width6  1//--- input parameters

//         int   LIN_1_STEP    =4; //line_1_power
//input int      LIN_1_PLECHO  =72; //Fast_line_1_leverage
//         int   LIN_2_STEP    =2;//line_2_power
//input int      LIN_2_PLECHO  =78; //Fast_line_2_leverage
//         int   LIN_3_STEP    =4;//line_3_power
//input int      LIN_3_PLECHO  =72; //Slow_line_1_leverage
//         int   LIN_4_STEP    =2;//Slow_line_4_power
//input int      LIN_4_PLECHO  =72;//Slow_line_2_leverage

input        int TOCHKA_VHODA = 300;// start_point
//input int           base  =450;
      int   point_shift_1 = 0;
      int   point_shift_2 = 0;
//input int   Multiplikator = 10;
//input int   InpSignalSMA  = 9;  // Signal SMA Period



//--- indicator buffers

double a1_Buffer[];
double a2_Buffer[];
double a3_Buffer[];
double a4_Buffer[];
double a5_Buffer[];
double a6_Buffer[];
//double a7_Buffer[];
//double a8_Buffer[];
/**/


//===========================================================================================
   double Znach;


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
 
//--- indicator buffers mapping
   SetIndexBuffer(0,a5_Buffer,INDICATOR_DATA);
   SetIndexBuffer(1,a6_Buffer,INDICATOR_DATA);
   SetIndexBuffer(2,a1_Buffer,INDICATOR_DATA);
   SetIndexBuffer(3,a2_Buffer,INDICATOR_DATA);
   SetIndexBuffer(4,a3_Buffer,INDICATOR_DATA);
   SetIndexBuffer(5,a4_Buffer,INDICATOR_DATA);
//----
//----
   SetIndexShift(2,-72);
   SetIndexShift(5,20);

//    if(TOCHKA_VHODA <= (LIN_1_PLECHO+25)*LIN_1_INTERVAL) TOCHKA_VHODA=(LIN_1_PLECHO+25)*LIN_1_INTERVAL;  
//    if(TOCHKA_VHODA <= (LIN_2_PLECHO+25)*LIN_2_INTERVAL) TOCHKA_VHODA=(LIN_2_PLECHO+25)*LIN_2_INTERVAL;  
//    if(TOCHKA_VHODA <= (LIN_3_PLECHO+25)*LIN_3_INTERVAL) TOCHKA_VHODA=(LIN_3_PLECHO+25)*LIN_3_INTERVAL;  
//    if(TOCHKA_VHODA <= (LIN_4_PLECHO+25)*LIN_4_INTERVAL) TOCHKA_VHODA=(LIN_4_PLECHO+25)*LIN_4_INTERVAL;  
//    if(TOCHKA_VHODA <= (base*2+25))                      TOCHKA_VHODA=(base*2+25);  

//------
//===========================================================================================
//===========================================================================================

   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {

   int i,z,limit;
//   int Bars=Bars(_Symbol,_Period);

   if(prev_calculated==0)// first calculation    
     {
      limit=rates_total-TOCHKA_VHODA;
      //--- set empty value for first limit bars
//Print("Bars=",Bars," rates_total=",rates_total," TOCHKA=",TOCHKA_VHODA," limit=",limit);
      if(limit<1)return(0);
      for(i=rates_total-1;i>=limit;i--)
      {
       a1_Buffer[i]=open[limit+1];
       a2_Buffer[i]=open[limit+1];
       a3_Buffer[i]=open[limit+1];
       a4_Buffer[i]=open[limit+1];
       a5_Buffer[i]=open[limit+1];
       a6_Buffer[i]=open[limit+1];
      }

     }
   else limit=rates_total-prev_calculated;
//--- main loop
   for(i=limit;i>=0 && !IsStopped();i--)
   {
//===========================================================================================
   Znach = 0; //iMA(NULL,0,base*2,0,MODE_SMA,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;

      a2_Buffer[i]=  3160*a1_Buffer[i]   -6240   *a1_Buffer[i+1 ]    +  3081*a1_Buffer[i+2 ];

      a4_Buffer[i+92]=a1_Buffer[i];   if(i<=10) { for(z=92-1;z>=0;z--){        a4_Buffer[i+0+z]=  5*a4_Buffer[i+1+z]  -  10*a4_Buffer[i+2+z]   +   10*a4_Buffer[i+3+z]  -  5*a4_Buffer[i+4+z]  +  1*a4_Buffer[i+5+z];  }}


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

//      a4_Buffer[i]=  2701*a3_Buffer[i]   -5328   *a3_Buffer[i+1 ]    +  2628 *a3_Buffer[i+2 ];



//================================================================================================================================================================================================
//================================================================================================================================================================================================

//   a5_Buffer[i] = (a2_Buffer[i+point_shift_1] - a4_Buffer[i+point_shift_2])* Multiplikator;

   } 
//----
//--- signal line counted in the 2-nd buffer

//     SimpleMAOnBuffer(rates_total,prev_calculated,0,InpSignalSMA,a5_Buffer,a6_Buffer);

//--- done

//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
附加的文件:
 

什么是差分微积分?

它是。

Δf(xk) = f (xk+1) - f (xk)

 
阿列克谢-潘菲洛夫

我提议在这个分支中收集关于差分微积分的指标和专家,以开放源码的方式。

我以一个更清晰的变体重写了该指标 作为例子。

在图表上,它看起来像这样。



蓝红线是通过杠杆为72的四度多项式进行插值(在区间内找一个点)。

      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;

蓝色细线是通过杠杆率为78的2度多项式进行外推(在区间外找到一个点)。

 a2_Buffer[i]=  3160*a1_Buffer[i]   -6240   *a1_Buffer[i+1 ]    +  3081*a1_Buffer[i+2 ];

红线是4次方的多项式的构造线。它被重新绘制,并以最后一个条形图的开盘点为基础。

 a4_Buffer[i+92]=a1_Buffer[i];   if(i<=10) { for(z=92-1;z>=0;z--){        a4_Buffer[i+0+z]=  5*a4_Buffer[i+1+z]  -  10*a4_Buffer[i+2+z]   +   10*a4_Buffer[i+3+z]  -  5*a4_Buffer[i+4+z]  +  1*a4_Buffer[i+5+z];  }}

 
叶夫根尼-别利亚耶夫

什么是差分微积分?

它是。

Δf(xk) = f (xk+1) - f (xk)


是的。

它与牛顿的二项式直接相关。

对于等距离的点来说,这是真的。

1*Y1-2*Y2+1*Y3=0 是直线的差异方程。

1*Y1-3*Y2+3*Y3-1*Y4=0--二度抛物线的差异方程。

1*Y1-4*Y2+6*Y3-4*Y4+1*Y5=0 - 三度抛物线的差分方程。

它也与这些主题有交集。

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

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

Как измерить скорость цены
Как измерить скорость цены
  • 2017.07.20
  • www.mql5.com
Всем привет, тут такая тема Хочу использовать "ускорение" цены на тиковых интервалах, но не пойму как вообще посчитать скорость цены...
 
阿列克谢-潘菲洛夫

是的。


这就是大家一直在做的事情......写作...

未来是否取决于过去?

 
叶夫根尼-别利亚耶夫

这就是大家一直在做的事情......写作...

未来是否取决于过去?


对于每一个行动,在现在都有一个痕迹,当然会影响到未来。:))))

我建议我们在这个主题中跳过哲学,让我们只讨论数学、编程、测试和优化。

 
阿列克谢-潘菲洛夫

是的。

与牛顿的二项式直接相关。

对于等距的点来说,这是真的。

Y1-2*Y2+Y3=0 - 直线的差分方程。

Y1-3*Y2+3*Y3-Y4=0--二阶抛物线的差分方程。

Y1-4*Y2+6*Y3-4*Y4+Y5=0 - 是三度抛物线的差分方程。

你试过这个配方吗?

Y = a0 + a1X + a2X^2 + a3X^3 + a4X^4

其中。

X是前一栏的价格。

Y - 当前条形图的价格。


于是我们得到了下面的图片。


 
尤苏夫霍贾-苏尔托诺夫

你试过这个配方吗?

Y = a + bX + cX^2 + dX^3 + eX^4


当然,在这种形式下,有X和Y,但在递归方程中,只有Y和所有的系数(a+bX+cX^2+dX^3+ eX^4)被减少,并由Y本身的五个值取代。

 

看了一下代码,我没看错吧,是某种反馈过滤器的变体?5061600、4926624和其他系数从何而来?

其实,独立的人是从哪里来的,互联网吗?))

 
阿列克谢-沃尔昌斯基

1.看了一下代码,我没看错吧,是某种带反馈的过滤器的变种?

2.那5061600、4926624等系数是怎么来的?

3.一般来说,感应器是从哪里来的,从网上来的?))

1.是的,这个过滤器有400年的历史,只有书面的历史:笛卡尔、牛顿、帕斯卡、泰勒、拉格朗日。

2.系数的计算。似乎在第二年,我们就已经熟悉了拉格朗日和泰勒的方法。似乎有很多计算系数的变体。

3.特别是这幅画是今天画的。:)))))

 

当样本增加到N=100时,第4度方程得到以下结果。