Machine learning in trading: theory, models, practice and algo-trading - page 620

 
Anatolii Zainchkovskii:

I will say otherwise, for example, I analyze just 10 bars from history to predict 1 bar in the future, a neural network will find hundreds of patterns from these 10 bars, and I suggest 1 pattern and train the neural network on the forwards.


It is unlikely that the NS will find something on its own, you still need to do statanalysis first, or it will find something that is not good enough. I'm still trying to adapt the NS to existing TS, just to avoid having to write all rules manually

You may take alglib and try it, you learn the NS in 5 lines

 
Maxim Dmitrievsky:

The NS is unlikely to find something on its own, first you still need to do statanalysis... or it will find something that is not clear. I still try to adapt the NS to existing TS, just not to prescribe all the rules manually

In any case, you can take alglib and try it, it trains the NS in 5 lines


When I read this I see that you've come to the Random Forest, as I've been told for a long time.... and about the statistical analysis I just said 50/50, I kept playing the robot and wrote the outcomes in a file... I can't see what signs may change or matter for the outcome, so I decided to let the neural network recognize something I can't see...

 
Anatolii Zainchkovskii:

So nowhere is there an example of how to use NS from Alglib, I used a search and came to this thread, saw that you tried to implement it. reading further I see that you came to the random forrest, which I have long been told about.... and about the stat analysis I just said that 50/50, I ran the robot and wrote outcomes in the file... I can't see what signs may change or matter for the outcome, so I decided to let a neural network recognize something I can't see...

Here is an example of Random Forest, using examples from the multiplication table to learn and then a trained one counts examples (gives answers in the log)
#include <Math\Alglib\dataanalysis.mqh>
//+------------------------------------------------------------------+
#define _rand(min,max) ((rand()/(double)SHORT_MAX)*((max)-(min))+min)
//+------------------------------------------------------------------+
void OnStart()
{
   MathSrand(1600);
   CDecisionForest      Trf;
   //CDecisionForestShell RFshell;
   CMatrixDouble        PatternsMatrix;
   CDFReport            RF_report;
   int RFinfo;
   double vector[2], out[1];
   
   // подготовка данных
   PatternsMatrix.Resize(100,3);
   int m=0;     // first pattern
   for(int i=1; i<=10; i++)
      for(int j=1; j<=10; j++)
      {
         PatternsMatrix[m].Set(0,i/10.0);       // input 1
         PatternsMatrix[m].Set(1,j/10.0);       // input 2
         PatternsMatrix[m].Set(2,(i*j)/100.0);  // target
         m++; //next pattern
      }
   // создание RF
   CDForest::DFBuildRandomDecisionForest(PatternsMatrix,100,2,1,500,0.95,RFinfo,Trf,RF_report);
   Print("Info=",RFinfo,"   RMSE Error=",DoubleToString(CDForest::DFRMSError(Trf,PatternsMatrix,100),5));  
   // проверка сети на целочисленных данных
   string s="Тест 1 >> ";
   for(int i=1; i<=10; i++)
   {
      int d1=(int)_rand(1,10), d2=(int)_rand(1,10);
      vector[0]=d1/10.0;
      vector[1]=d2/10.0;
      CDForest::DFProcess(Trf,vector,out);
      s+=(string)d1+"*"+(string)d2+"="+DoubleToString(out[0]*100,0)+" // ";
   }
   Print(s);
   // проверка сети на дробныx данных
   s="Тест 2 >> ";
   for(int i=1; i<=5; i++)
   {
      double d1=NormalizeDouble(_rand(1,10),1), d2=NormalizeDouble(_rand(1,10),1);
      vector[0]=d1/10.0;
      vector[1]=d2/10.0;
       CDForest::DFProcess(Trf,vector,out);
      s+=DoubleToString(d1,1)+"*"+DoubleToString(d2,1)+"="+DoubleToString(out[0]*100,2)+
         "("+DoubleToString(d1*d2,2)+") // ";
   }
   Print(s);
}
and here is an example for MLP https://www.mql5.com/ru/forum/8265/page2#comment_333746
Библиотеки: ALGLIB - библиотека численного анализа
Библиотеки: ALGLIB - библиотека численного анализа
  • 2012.10.12
  • www.mql5.com
Статьи и техническая библиотека по автоматическому трейдингу: Библиотеки: ALGLIB - библиотека численного анализа
 
Maxim Dmitrievsky:

Well, the portfolio is unsteady, it doesn't go from sigma to sigma, but cracks periodically... and then it recalculates and cracks again

It should not go from sigma to sigma, it should live as long as cointegration between rows is alive.


PS. Co-integration is when you added two non-stationary series in a special way and got a stationary series by virtue of this special addition. There is a special test for this. This idea is widely used by portfolio managers.

There are a lot of tests that guarantee that there is no "crash".

 
SanSanych Fomenko:

It should not go from sigma to sigma, but should live as long as the cointegration between rows is alive.


PS. Co-integration is when you added two non-stationary series in a special way and got a stationary series by virtue of this special addition. There is a special test for this. This idea is widely used by portfolio managers.

There are a lot of tests that guarantee against "crapshoot".


I didn't know :) there are other "variations on this theme"

and without tests you can see everything in the tester

https://www.mql5.com/ru/code/19630

Cointegration
Cointegration
  • votes: 18
  • 2017.12.26
  • Maxim Dmitrievsky
  • www.mql5.com
Индикатор находит коэффициенты линейной регрессии для каждого из выбранных инструментов со всеми остальными, и выводит на график в виде стандартных отклонений. Сумма всех кривых...
 
Maxim Dmitrievsky:
Here is an example of Random Forest, on examples from the multiplication table learns and then already trained counts examples (gives answers in the log)
and here is an example for MLP https://www.mql5.com/ru/forum/8265/page2#comment_333746

what a gift. thank you Max!!!

 
Maxim Dmitrievsky:

I did not know :) there are other "variations on the theme"

and without tests you can see everything in the tester

https://www.mql5.com/ru/code/19630

I did not see any proof that your indicator has something to do with the word "cointegration". The orange line seems to be a clearly non-stationary series, while it should be stationary, although the sample is small, so cointegration must be proved.
 
SanSanych Fomenko:
I didn't see any evidence that your indicator has anything to do with the word "cointegration". The piece of graph - orange line apparently, it looks obviously non-stationary series, and it should be stationary, although the sample is small, so cointegration must be proved.

cointegration is a linear relationship between time series having a stationary series, all true

The symbols need to be chosen... it can count linear regression for a lot of symbols, not just 2 symbols. Even worse, for 2 will not count correctly, because it recalculates the linear regression 2 times, because he originally made multicurrency. There is a bot, the results were thrown in another topic. It earns on some indices, which have explicit dependence, but the profit is small, about 100% per annum.

There is the same shit, but through a non-linear model, but it is based on increments and not on raw prices.

P.s. I haven't seen a single person who successfully trades cointegrated instruments in forex (because there are almost none). Because no matter how you wriggle, and if there is no fundamental dependence, then there is none.
 
SanSanych Fomenko:
I didn't see any evidence that your indicator has anything to do with the word "cointegration". The orange line seems to be obviously non-stationary series, while it should be stationary, although the sample is small, so cointegration must be proved.

The first one shows cointegration and the channel is built, and the second one shows how this very cointegration is overlapping...

Here is another example of how cointegration collapses...
Files:
g7p4.png  47 kb
0zz22.PNG  56 kb
 
Maxim Dmitrievsky:

cointegration is a linear relationship between time series having a stationary series, all true

The symbols need to be chosen... it can count linear regression for a lot of symbols, not just 2. Even worse, for 2 will not count correctly, because it recalculates the linear regression 2 times, because he originally made multicurrency. There is a bot, the results were thrown in another topic. It earns on some indices, which have explicit dependence, but the profit is small, about 100% per annum.

There is the same shit, but through a non-linear model, but it is counted in increments and not the naked prices.

p.s. I haven't seen a single person successfully trading cointegrated instruments in forex (because there are almost none)

There are no serious people in forex - it's a penny betting market. That's why it's not an indicator.

I have such a model, but it is limited by spread, which is variable.

Vector autoregression models are widely used in other markets, plenty of ready-made tools. Granger is flourishing.

Reason: