Please review my code

Lativ_  

Hi there

I'm trying to collect data for training a network. 

This data is simple, just time taken for the price to move x amount of points.

Every x points move record time. I'll call these recordings singles, but I don't want to record them as singles but by groups of 2 3 4 5 and so on

just like Fibo sequence, I want to add up these singles like this:  if there is 2 singles, add them up and place them into a 2s box and if there's 3 singles, add them up and place them into the 3s box...


The code below works as it should. If someone has time, please advice me how I can improve or write it better. Also how can I make the ARRAYS as vectors? like in C++ vector<double> p2? and what if I want

the ARRAYS to be dynamic?

Thank you.

#include <Trade\SymbolInfo.mqh>
//--- The SymbolInfo Class Object
CSymbolInfo mysymbol;
MqlDateTime lastdate;
double first = 0.0, last = 0.0, piece = 0.0, review = 0.0;
int count = 1, seconds = 0, entry = 0, entry2 = 0, total = 0;
//Arrays
double p1[2], p2[2000], p3[2000], p4[2000], p5[2000], p6[2000],
       p7[2000], p8[2000], p9[2000], p10[2000];
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   mysymbol.Name(Symbol());
   EventSetTimer(10);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   EventKillTimer();
//---
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double dif(double one_, double two_)//Check for negative values
  {
   double r = 0.0;
   if(one_ - two_ < 0.0)
      r = NormalizeDouble((one_ - two_) * -1, _Digits);
   if(one_ - two_ > 0.0)
      r = NormalizeDouble(one_ - two_, _Digits);
   return(r);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTimer()
  {
   TimeCurrent(lastdate);
   if(!mysymbol.RefreshRates())
     {
      Alert("Error getting the latest price quote - error:", GetLastError(), "!!");
      return;
     }
   //total = count;
   if(lastdate.hour == 0 && lastdate.min < 5)//Start from daily open
     {
      entry = 0;
      entry2 = 0;
      count = 1;
      return;
     }
     
   seconds++;// keep time, how long until next 10 points move
   
   if(first == 0.0)//if its the first calculation
     {
      double ini = 0.0;
      ini = iOpen(_Symbol, PERIOD_D1, 0);
      if(dif(mysymbol.Bid(), ini) >= 10 * _Point)
        {
         first = NormalizeDouble(mysymbol.Bid() - ini, _Digits) * seconds;
         save(NormalizeDouble(first, _Digits), count);
         count++;
         seconds = 0;
         last = mysymbol.Bid();
        }
     }
   else
     {
      if(dif(mysymbol.Bid(), last) >= 10 * _Point)
        {
         first = NormalizeDouble(mysymbol.Bid() - last, _Digits) * seconds;
         save(NormalizeDouble(first, _Digits), count);
         count++;
         seconds = 0;
         last = mysymbol.Bid();
        }
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void save(double data, int no)
  {
   if(entry >= 2)//keeping p1 array with only 2 values to hold
     {
      review = p1[1];
      entry = 0;
     }
     
   printf("New data %f:\n", data);
   p1[entry] = data;
   if(no >= 2 && no < 2000)//if there is 2 or more data, record it
     {
      Add(no, entry);
     }
   entry++;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Add(int no, int n)
  {
   double c1 = 0.0;
   int entry3 = entry2 - 1, entry4 = entry2 - 2, entry5 = entry2 - 3, entry6 = entry2 - 4,
       entry7 = entry2 - 5, entry8 = entry2 - 6, entry9 = entry2 - 7, entry10 = entry2 - 8;
   if(n == 0)
     {
      printf("Load P2 for %d times  %f + %f ", entry2, p1[0], review);
      p2[entry2] = p1[0] + review;
      c1 = review;
     }
   else
     {
      printf("Load P2 for %d times  %f + %f ", entry2, p1[0], p1[1]);
      p2[entry2] = p1[0] + p1[1];
      c1 = p1[1];
     }
     
     
   if(no >= 3)
     {
      printf("Load P3 for %d times  %f + %f", entry3, p2[entry2 - 1], c1);
      p3[entry3] = p2[entry2 - 1] + c1;
     }
     
     
   if(no >= 4)
     {
      printf("Load P4 %d times  %f + %f", entry4, p3[entry3 - 1], c1);
      p4[entry4] = p3[entry3 - 1] + c1;
     }
     
     
   if(no >= 5)
     {
      printf("Load P5 %d times  %f + %f", entry5, p4[entry4 - 1], c1);
      p5[entry5] = p4[entry4 - 1] + c1;
     }
     
     
   if(no >= 6)
     {
      printf("Load P6 %d times  %f + %f", entry6, p5[entry5 - 1], c1);
      p6[entry6] =  p5[entry5 - 1] + c1;
     }
     
     
   if(no >= 7)
     {
      printf("Load P7 %d times  %f + %f", entry7,  p6[entry6 - 1], c1);
      p7[entry7] = p6[entry6 - 1] + c1;
     }
     
     
   if(no >= 8)
     {
      printf("Load P8 %d times  %f + %f", entry8, p7[entry7 - 1], c1);
      p8[entry8] = p7[entry7 - 1] + c1;
     }
     
     
   if(no >= 9)
     {
      printf("Load P9 %d times  %f + %f", entry9, p8[entry8 - 1], c1);
      p9[entry9] = p8[entry8 - 1] + c1;
     }
     
     
   if(no >= 10)
     {
      printf("Load P10 %d times  %f + %f", entry10, p9[entry9 - 1], c1);
      p10[entry10] = p9[entry9 - 1] + c1;
     }
     
   entry2++;
  }
/*/+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double OnTester()
  {
   string file_name = "DATA.csv";
//---
   int handle = FileOpen(file_name, FILE_CSV | FILE_WRITE | FILE_COMMON);
   if(handle == INVALID_HANDLE)
     {
      Print("no data Err=", GetLastError());
     }
//---
   if(handle > 0)
     {
      FileWrite(handle, "P2", "P3", "P4", "P5", "P6", "P7", "P8", "P9", "P10");
      for(int i = 0; i < total ; i++)
        {
         string str1 = DoubleToString(p2[i], _Digits);
         string str2 = DoubleToString(p3[i], _Digits);
         string str3 = DoubleToString(p4[i], _Digits);
         string str4 = DoubleToString(p5[i], _Digits);
         string str6 = DoubleToString(p6[i], _Digits);
         string str7 = DoubleToString(p7[i], _Digits);
         string str8 = DoubleToString(p8[i], _Digits);
         string str9 = DoubleToString(p9[i], _Digits);
         string str10 = DoubleToString(p10[i], _Digits);
         FileWrite(handle, str1, str2, str3, str4, str6, str7, str8, str9, str10);
        }
     }
   double r = double(FileSize(handle));
   FileClose(handle);
   return(r);
  }*/
//+------------------------------------------------------------------+
Reason: