微分積分、例

 

このスレッドで、差分計算に関する指標や専門家をオープンソースコードで集めることを提案します。

興味をもってもらえれば、いずれは役に立つものを作ったり、描いたりすることになるでしょう。:)

例としてインジケータを 分かりやすく書き直しました。

//|                                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の4次多項式による補間(区間内の点を見つけること)です。

      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 - 2次放物線の差分方程式。

1*Y1-4*Y2+6*Y3-4*Y4+1*Y5=0 - 3次の放物線の差分方程式です。

トピックスとも重なります。

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 - 2次放物線の差分方程式。

Y1-4*Y2+6*Y3-4*Y4 + Y5 =0 - は3次放物線の差分方程式である。

この処方を試されましたか?

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自身の5つの値に置き換えている。

 

コードを見てみると、フィードバックフィルタの一種であることは間違いないでしょうか?5061600、4926624などの係数はどこから来ているのでしょうか?

実は、インディーはどこから来たかというと、インターネットです。))

 
アレクセイ・ヴォルチャンスキー

1.コードを見てみると、これはフィードバック付きのフィルタの一種であることがわかりました。

2.また、5061600、4926624などの係数はどこから来たのでしょうか?

3.一般的に、インダクターはどこから来たのか、ネットから?))

1.デカルト、ニュートン、パスカル、テイラー、ラグランジュと、400年前に書かれた歴史しかないフィルターなんです。

2.係数が算出されます。2年目にはラグランジュやテイラーの手法を知ることができたようです。係数の計算には多くのバリエーションがあるようです。

3.特にこの作品は、今日描いたものです。:)))))

 

サンプルをN=100に増やすと、4次式で次のような結果になる。


理由: