Advisors on neural networks, sharing experiences.

 

There is little information on the forum about ready-made solutions and the effectiveness of neural networks for trading in the market. I suggest discussing and sharing experience here. If there is already a thread with discussion, please link to it.

I am using classes from here, simple multilayer Perspectron. I hope classes count correctly, I am counting on the author's experience. Started experimenting, interesting :)

At the moment I have 11 indices on input, output is a zigzag, shifted by 1 bar into the future.

These are the results of my 8 month grid. I am training on 1000 bars, 10000 epochs, 70 neurons in a hidden layer. Signals are reversed and purely by neural network, without additional filters. 15 min tf.

 

Zigzag code

//+------------------------------------------------------------------+
//|                                                       FastZZ.mq5 |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, Yurich"
#property link      "https://login.mql5.com/ru/users/Yurich"
#property version   "1.00"
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots 1
#property  indicator_label1  "ZZ"
#property  indicator_type1   DRAW_ZIGZAG
#property  indicator_color1  clrRed
#property  indicator_style1  STYLE_SOLID
#property  indicator_width1  1
//+------------------------------------------------------------------+
input int Depth=2000; // Minimum points in a ray
//+------------------------------------------------------------------+
double zzH[],zzL[];
double depth;//, deviation;
int last,direction;
//+------------------------------------------------------------------+
void OnInit()
  {
   SetIndexBuffer(0,zzH,INDICATOR_DATA);
   SetIndexBuffer(1,zzL,INDICATOR_DATA);
   IndicatorSetInteger(INDICATOR_DIGITS,Digits());
   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0);
   PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,0.0);
   depth=Depth*_Point;
//deviation=10*_Point;
   direction=1;
   last=0;
  }
//+------------------------------------------------------------------+
int OnCalculate(const int total,
                const int calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick[],
                const long &real[],
                const int &spread[])
  {
   if(calculated==0) last=0;
   for(int i=calculated>0?calculated-1:0; i<total-1; i++)
     {
      bool set=false;
      zzL[i]=0;
      zzH[i]=0;
      //---
      if(direction>0)
        {
         if(high[i]>zzH[last])//-deviation)
           {
            zzH[last]=0;
            zzH[i]=high[i];
            if(low[i]<high[last]-depth)
              {
               if(open[i]<close[i]) zzH[last]=high[last]; else direction=-1;
               zzL[i]=low[i];
              }
            last=i;
            set=true;
           }
         if(low[i]<zzH[last]-depth && (!set || open[i]>close[i]))
           {
            zzL[i]=low[i];
            if(high[i]>zzL[i]+depth && open[i]<close[i]) zzH[i]=high[i]; else direction=-1;
            last=i;
           }
        }
      else
        {
         if(low[i]<zzL[last])//+deviation)
           {
            zzL[last]=0;
            zzL[i]=low[i];
            if(high[i]>low[last]+depth)
              {
               if(open[i]>close[i]) zzL[last]=low[last]; else direction=1;
               zzH[i]=high[i];
              }
            last=i;
            set=true;
           }
         if(high[i]>zzL[last]+depth && (!set || open[i]<close[i]))
           {
            zzH[i]=high[i];
            if(low[i]<zzH[i]-depth && open[i]>close[i]) zzL[i]=low[i]; else direction=1;
            last=i;
           }
        }
     }
//----
   zzH[total-1]=0;
   zzL[total-1]=0;
   return(total);
  }
//+------------------------------------------------------------------+

The indicator buffers contain only high and low values, I fill the intermediate data in the loop, converting it to 1 - rising on the current bar, -1 falling. Seems to be correct, but if there are mistakes, please correct me

void FillZZarray()
{
  ArrayResize(zz,vector);   
   int lastcountbar = 0;
   for(int i=0;i<vector;i++) // Заполняем массив выходов
     {
      if(zzH[i]>0)  
       {
        zz[i]=1; lastcountbar = 1;
        if(i!=0)
          for(int q=i-1;q>=0;q--)
           {
            if(zz[q]==0)zz[q]=lastcountbar;
           } 
       }    
      if(zzL[i]>0) 
       {
        zz[i]=-1; lastcountbar = -1; 
        if(i!=0)
          for(int q=i-1;q>=0;q--)
           {
            if(zz[q]==0)zz[q]=lastcountbar;
           } 
       } 
      if(zzH[i]==0 && zzL[i]==0) zz[i] = lastcountbar;
     }
}
 
Cool! Only when putting it on the real, swap the buy and sell signals.
 
Vladimir Tkach:
Cool! Only when you put it on the real, change the positions of the buy and sell signals.
Why? )
 
Maxim Dmitrievsky:
Why? )
The omen is this. After testing.
 
Vladimir Tkach:
The omen is this. After testing.
Seriously, though, let's get on with it, if you've got it.) It's not like I'm here to play games :)
 
Maxim Dmitrievsky:
No, seriously... let's talk about it, if you've got something.) It's not like I'm here to play games :)
Try this one for a tutorial.
Sampler
Sampler
  • votes: 33
  • 2012.06.01
  • Serj
  • www.mql5.com
Индикатор i_Sampler рассчитывает идеальные входы, предназначен для обучения нейросети.
 
Sergey Chalyshev:
Try this inductor for training.

I need a vector of input data for training, and here the signals are interrupted - then buy, then sell, then skips... and I don't know how to fill them in, not with zeros... I don't know how to fill them with zeros... Zigzag, in my opinion, provides inputs that are no less perfect, but I may be wrong... I'm not very experienced in neural networks yet...

 
Maxim Dmitrievsky:

I need a vector of input data for training, and here the signals are interrupted - then buy, then sell, then skips... and I don't know how to fill them in, not with zeros... I don't know how to fill them with zeros, it's not clear... Zigzag, in my opinion, provides no less perfect inputs, but I may be wrong... I'm not very experienced in neural networks yet...

The indicator has two types of signals, discrete and analogue to choose from. Fill in the gaps with zeros.

Is the picture in the first post on the training sample? If it is out of sample then it is interesting to see on training sample, with so many neurons the network should memorize all input data by heart.

 
Sergey Chalyshev:

There are two types of signal in the indicator, discrete and analogue to choose from. Fill in the gaps with zeros.

Is the picture in the first post a training sample? If it's out of sample then it's interesting to look at the training sample, with so many neurons the network should memorise all the input data by heart.

The training sample is the last 1000 bars, or rather the first if you look from 0th as in time series, everything before that is out of sample.

I'll try it tomorrow and see what it shows. So far screwed the second zigzag, bigger one, looking at how it works on 2 outputs. Nothing outstanding so far, works on average at zero :)

 
Maxim Dmitrievsky:

on average works at zero :)

That's why you were suggested to switch from buy to sell.

I have not yet heard of anyone making stable money on neural networks, it is very unstable. The simplest TS on the muwings - and they work more stable.

Reason: