差分微积分,例子。 - 页 8

 
尤里-阿索连科


RU的优势是什么?

根本没有声称有什么优势。

在我看来。

如果我们最初对要建模的系统(甚至是一个复杂的系统:飞机、汽车)有一定的想象,那么立即对空间进行标记(如笛卡尔系统)并使用整个数学仪器对系统进行建模会更方便。"从头设计 "的方法

如果你对这个系统没有一个完整的了解(接近森林、沼泽或外汇:)我说的是我自己),那么你必须依靠已经采取的步骤和一个相当狭窄的视野。这更接近于差分(递归)微积分。一种 "从底部研究 "的方法。算 法甚至允许在几个步骤的基础上了解在"从顶层设计 "的方法 方面正在发生什么。

在这个比喻中,神经网络是一个有无人机的系统--探针探测,建议路径,并提供整体情况。在探索的过程中,它将对所观察到的东西的意义和所做的选择做出许多程序化的决定。就我个人而言,我并不总是愿意(甚至是被迫:))依赖别人的决定。 :)))))


我尽我所能地回答。))只是我们又离菲洛-索菲亚只有一步之遥。我不想去那里。))

关于交易、自动交易系统和交易策略测试的论坛。

差分微积分,例子。

Aleksey Panfilov, 2018.01.10 16:51


我建议,在这个问题上没有哲学,只有数学、编程、测试、优化。


 
尼古拉-森科

在我看来,SMA的SMA是 "见仁见智 "的,顺便说一下,关于Fourier。也许我们会再到那里去。

P/S 01.02.2018 我认为也有区别,试着在这一行重复你的Banzai.mq4指标

均线本质上是一个锯齿,只是非常细,所以在取第二个差值时,我假设指标的锯齿线。

 
阿列克谢-潘菲洛夫

当然,随后的差异也可以被认为是新的信息。

然而,在第一个差异上,我就不太清楚我们在画哪条代数线。而随着 "杠杆 "的增加,一切都在那里变得混乱起来。))))

例如,这里是使用价格增量作为新信息的另一种变体。这里的增量被明确解读为差值。

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;
在图中你可以看到,由五度的多项式(由连接点的数量)有条件地构建的线(红色)也开始稳定地停留在图形附近。


这就好像通过在第一个差额(价格增量)上使用四次方的多项式,我们已经将(通过点数)的力量增加到了五次方。

关于交易、自动交易系统和策略测试的论坛

差分微积分,例子。

Maxim Dmitrievsky, 2018.01.31 05:37

矩阵已经简单地退化了:) 在这种情况下,要使用正则化,减少度数。
是这样吗, 规范化?



附加的文件:
 
我认为,perseptron是最好的差异计算。这就是我使用的东西。
 

关于交易、自动交易系统和交易策略测试的论坛

差分微积分,例子。

Aleksey Panfilov, 2018.01.10 18:34

我想我们将进入专家顾问和优化阶段。

为了优化,我们将在信息51 中描述的指标中增加改变外推的杠杆的可能性。用三度的多项式进行外推。

//|                                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
Предлагаю собрать в эту ветку индикаторы и эксперты на разностном исчислении, в открытом коде...
附加的文件:
 

为了看到这个指标的可能性,让我们使用众所周知的移动平均线.mq4专家顾问。

作为一个单一的信号,我们将使用两条曲线的交叉。让我们做一些改变。

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

欧元兑美元,M15,那个2点的价差就在那里。

对不起,我不能把代码放进去。

附加的文件:
 
Renat Akhtyamov:

对不起,但我不能把代码放下。

在任何情况下,最后几条都会被重新绘制,这意味着代码的值=0。
 
Renat Akhtyamov:

欧元兑美元,M15,那个2点的价差就在那里。

对不起,但我不能把代码

关于"四位数"?