微分積分、例 - ページ 8

 
ユーリイ・アサウレンコ


RUのメリットは何ですか?

アドバンテージを全く主張しない

私見ですが。

モデリングするシステムのイメージ(飛行機や車など複雑なものでも)がある程度確実に想像できれば、すぐに空間(例えばデカルト系)をマークアップして、数学的装置全体を使ってシステムをモデリングする方が便利である。トップからのデザイン」というアプローチ。

システムの全体像(森や沼、FXに アプローチする)自分のことです)を把握できていなければ、すでに行われた手順やかなり狭い視野に頼らざるを得ません。これは差分(recurrence)微積分に近い。底辺からの研究」というアプローチ。ア ルゴリズムは、「上から目線の設計」という観点から、わずかなステップでも何が起こっているかを理解することを可能にします。

この例えによれば、ニューラルネットワークは、ドローン(探査機)を持つシステムであり、探査機が道を探り、道を示唆し、全体像を提供するのである。探索の過程で、観察されていることの意義や選択について、多くのプログラムによる 判断を行うことになります。個人的には、他人の判断に左右されるのは、必ずしも好ましくない(というか、そうせざるを得ない)。


私は精一杯答えた。)) またフィロソフィアまであと一歩のところまで来てしまっただけです。行きたくありません。))

トレーディング、自動売買システム、トレーディング戦略のテストに関するフォーラム。

微分積分、例

アレクセイパンフィロフ さん 2018.01.10 16:51


このスレッドには哲学はなく、数学、プログラミング、テスト、最適化だけであることを提案します。


 
ニコライ・セムコ

SMAによるSMAは、私見では「見る人の目の中にある」、ついでにフーリエについても。もしかしたら、もう少し行けるかもしれません。

P/S 2018.02.01 私も違いがあると思います、このラインでBanzai.mq4インジケータを繰り返してみて ください。

SMAはもともと非常に細かいノコギリ波なので、2回目の差を取るときはインジケーターのノコギリ波を想定しています。

 
アレクセイ・パンフィロフ

もちろん、その後の差分も新しい情報と考えることができる。

しかし、最初の違いですでに、どのような代数的な線を描いているのか、私にはよくわからない。そして、「レバレッジ」が高まると、そこですべてが混同されてしまうのです。))))

例えば、価格増分を新しい情報として利用する別のバリエーションを紹介しよう。ここでは、インクリメントを差分として明示的に読み取っている。

1*y1-1*y2-2*y2+3*y3-1*y4 =0

1*y1-1*y2-3*y2+6*y3-4*y4 + 1*y5 =0

1*y1-1*y2-4*y2+10*y3-10*y4 + 5*y5 -1*y6=0

1*y1-1*y2-5*y2+15*y3-20*y4 + 15*y5 -6*y6 + 1*y7=0

1*y1-1*y2-6*y2+21*y3-35*y4 + 35*y5 -21*y6 + 7*y7 -1*y8=0


2*y2=1*y1-1*y2+3*y3-1*y4

3*y2=1*y1-1*y2+6*y3-4*y4 + 1*y5

4*y2=1*y1-1*y2+10*y3-10*y4 + 5*y5 -1*y6

5*y2=1*y1-1*y2+15*y3-20*y4 + 15*y5 -6*y6 + 1*y7

6*y2=1*y1-1*y2+21*y3-35*y4 + 35*y5 -21*y6 + 7*y7 -1*y8

      a1_Buffer[i]=(open[i]-open[i+1]   +3*a1_Buffer[i+1 ]   -1*a1_Buffer[i+2 ]  )/2;
      a2_Buffer[i]=(open[i]-open[i+1]   +6*a2_Buffer[i+1 ]   -4*a2_Buffer[i+2 ]   +1*a2_Buffer[i+3 ]  )/3;
      a3_Buffer[i]=(open[i]-open[i+1]   +10*a3_Buffer[i+1 ]  -10*a3_Buffer[i+2 ]  +5*a3_Buffer[i+3 ]  -1*a3_Buffer[i+4 ])/4;
      a4_Buffer[i]=(open[i]-open[i+1]   +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 ])/5;
      a5_Buffer[i]=(open[i]-open[i+1]   +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 ])/6;
写真では、次数5の多項式(連結点の数)で条件付きに作られた線(赤)も、着実にグラフの近くに留まり始めていることがわかる。


まるで、最初の差(価格差)に4乗の多項式を使うことで、5乗に(点数分)増やしたような感じです。

トレーディング、自動売買システム、ストラテジーテストに関するフォーラム

微分積分、例

マキシム・ドミトリエフスキー 2018.01.31 05:37

行列が単純に縮退している :) このような場合,正則化を 行い,次数を減らしていく
これって、 正則化?



ファイル:
 
ペルセプトロンは最高の差分計算機だと思います。私が使っているのはこれです。
 

最適化のため、メッセージ51で 説明した指標に、外挿のレバレッジを変更できる機能を追加する予定です。3次の多項式による外挿。

//|                                Copyright 2018, 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  clrYellow
#property indicator_style2  STYLE_SOLID
#property indicator_width2  3
//--- plot a3_
#property indicator_label3  "Fast_line_1"
#property indicator_type3   DRAW_LINE
#property indicator_color3  clrSilver
#property indicator_style3  STYLE_SOLID
#property indicator_width3  8
//--- 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  3
//--- 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  3
//--- 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  3//--- 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 leverage = 72;
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,0);
   SetIndexShift(0,20);
   SetIndexShift(3,92-leverage);
   SetIndexShift(4,38);
   SetIndexShift(5,56);
   SetIndexShift(1,74);

//    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;

      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]; 
      
//      a3_Buffer[i+38]=a5_Buffer[i+38]; 
      
//      a4_Buffer[i+56]=a5_Buffer[i+56];
        
//      a6_Buffer[i+74]=a5_Buffer[i+74];
      
 //     a4_Buffer[i+92]=a1_Buffer[i];   if(i<=1) { 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+292]=a2_Buffer[i];   if(i<=1) { for(z=292-1;z>=0;z--){         a3_Buffer[i+0+z]=  2.998096443*a3_Buffer[i+1+z]  -  2.998096443*a3_Buffer[i+2+z]   +   1*a3_Buffer[i+3+z]   ;  }}

 //     a5_Buffer[i+92]=a2_Buffer[i];   if(i<=1) { 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]   ;  }}

 //     a6_Buffer[i+292]=a2_Buffer[i];   if(i<=1) { for(z=292-1;z>=0;z--){         a6_Buffer[i+0+z]=  3.998096443*a6_Buffer[i+1+z]  -  5.996192886*a6_Buffer[i+2+z]   +   3.998096443*a6_Buffer[i+3+z]  -  1*a6_Buffer[i+4+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

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

//--- done

//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+


Разностное исчисление, примеры.
Разностное исчисление, примеры.
  • 2018.01.18
  • www.mql5.com
Предлагаю собрать в эту ветку индикаторы и эксперты на разностном исчислении, в открытом коде...
 

この指標の可能性を見るために、よく知られているMoving Average.mq4 Expert Advisorを使用してみましょう。

1つの信号として、2つの曲線の交差を使用します。何か変化を起こそう。

//+------------------------------------------------------------------+
//|                                               Moving Average.mq4 |
//|                   Copyright 2005-2014, MetaQuotes Software Corp. |
//|                                              http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright   "2005-2014, MetaQuotes Software Corp."
#property link        "http://www.mql4.com"
#property description "Moving Average sample expert advisor"

#define  MAGICMA  20131111
//--- Inputs
input double Lots          =0.1;
input double MaximumRisk   =0.02;
input double DecreaseFactor=3;
input int    leverage_1  =72;
input int    leverage_2  =56;
//input int    MovingPeriod  =12;
//input int    MovingShift   =6;
//+------------------------------------------------------------------+
//| Calculate open positions                                         |
//+------------------------------------------------------------------+
int CalculateCurrentOrders(string symbol)
  {
   int buys=0,sells=0;
//---
   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGICMA)
        {
         if(OrderType()==OP_BUY)  buys++;
         if(OrderType()==OP_SELL) sells++;
        }
     }
//--- return orders volume
   if(buys>0) return(buys);
   else       return(-sells);
  }
//+------------------------------------------------------------------+
//| Calculate optimal lot size                                       |
//+------------------------------------------------------------------+
double LotsOptimized()
  {
   double lot=Lots;
   int    orders=HistoryTotal();     // history orders total
   int    losses=0;                  // number of losses orders without a break
//--- select lot size
   lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/1000.0,1);
//--- calcuulate number of losses orders without a break
   if(DecreaseFactor>0)
     {
      for(int i=orders-1;i>=0;i--)
        {
         if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false)
           {
            Print("Error in history!");
            break;
           }
         if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL)
            continue;
         //---
         if(OrderProfit()>0) break;
         if(OrderProfit()<0) losses++;
        }
      if(losses>1)
         lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,1);
     }
//--- return lot size
   if(lot<0.1) lot=0.1;
   return(lot);
  }
//+------------------------------------------------------------------+
//| Check for open order conditions                                  |2018_02_02_EMA_Polynom_s4_s3_p72_v.2
//+------------------------------------------------------------------+
void CheckForOpen()
  {
   double ma_1,ma_2,ma_1_P,ma_2_P;
   int    res;
//--- go trading only for first tiks of new bar
//   if(Volume[0]>1) return;
//--- get Moving Average 
//   ma=iMA(NULL,0,MovingPeriod,MovingShift,MODE_SMA,PRICE_CLOSE,0);
 ma_1=iCustom(NULL,0,"2018_02_02_EMA_Polynom_s4_s3_p72_v.2",leverage_1,300,3,0);
 ma_2=iCustom(NULL,0,"2018_02_02_EMA_Polynom_s4_s3_p72_v.2",leverage_2,300,3,0);
 ma_1_P=iCustom(NULL,0,"2018_02_02_EMA_Polynom_s4_s3_p72_v.2",leverage_1,300,3,1);
 ma_2_P=iCustom(NULL,0,"2018_02_02_EMA_Polynom_s4_s3_p72_v.2",leverage_2,300,3,1);
//--- sell conditions
   if(ma_2_P < ma_1_P && ma_1 < ma_2)
     {
      res=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,0,0,"",MAGICMA,0,Red);
      return;
     }
//--- buy conditions
   if(ma_2_P > ma_1_P && ma_1 > ma_2)
     {
      res=OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,0,0,"",MAGICMA,0,Blue);
      return;
     }
//---
  }
//+------------------------------------------------------------------+
//| Check for close order conditions                                 |
//+------------------------------------------------------------------+
void CheckForClose()
  {
   double ma_1,ma_2,ma_1_P,ma_2_P;
//--- go trading only for first tiks of new bar
//   if(Volume[0]>1) return;
//--- get Moving Average 
//   ma=iMA(NULL,0,MovingPeriod,MovingShift,MODE_SMA,PRICE_CLOSE,0);
 ma_1=iCustom(NULL,0,"2018_02_02_EMA_Polynom_s4_s3_p72_v.2",leverage_1,300,3,0);
 ma_2=iCustom(NULL,0,"2018_02_02_EMA_Polynom_s4_s3_p72_v.2",leverage_2,300,3,0);
 ma_1_P=iCustom(NULL,0,"2018_02_02_EMA_Polynom_s4_s3_p72_v.2",leverage_1,300,3,2);
 ma_2_P=iCustom(NULL,0,"2018_02_02_EMA_Polynom_s4_s3_p72_v.2",leverage_2,300,3,2);
//---
   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
      if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue;
      //--- check order type 
      if(OrderType()==OP_BUY)
        {
         if(ma_2_P <= ma_1_P && ma_1 < ma_2)
           {
            if(!OrderClose(OrderTicket(),OrderLots(),Bid,3,White))
               Print("OrderClose error ",GetLastError());
           }
         break;
        }
      if(OrderType()==OP_SELL)
        {
         if(ma_2_P >= ma_1_P && ma_1 > ma_2)
           {
            if(!OrderClose(OrderTicket(),OrderLots(),Ask,3,White))
               Print("OrderClose error ",GetLastError());
           }
         break;
        }
     }
//---
  }
//+------------------------------------------------------------------+
//| OnTick function                                                  |
//+------------------------------------------------------------------+
void OnTick()
  {
//--- check for history and trading
   if(Bars<100 || IsTradeAllowed()==false)
      return;
//--- calculate open orders by current symbol
   if(CalculateCurrentOrders(Symbol())==0) CheckForOpen();
   else                                    CheckForClose();
//---
  }
//+------------------------------------------------------------------+
 


ファイル:
2018_02_02.zip  523 kb
 

EURUSD、M15、その2ポイントのスプレッドがある。

申し訳ありませんが、コードを入れることができません。

ファイル:
 
Renat Akhtyamov:

申し訳ないが、コードを置くことができない。

いずれにせよ、最後の数本のバーが再描画されるので、コードの値=0となる。
 
Renat Akhtyamov:

EURUSD、M15、その2ポイントのスプレッドがある。

申し訳ありませんが、コードを入れることができません

4ケタ」に?