//+------------------------------------------------------------------+
//|                                                     MULTICUR.mq4 |
//|                                               Edward Samokhvalov |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Edward Samokhvalov"
#property indicator_separate_window
extern string inFile = "Volumes.csv";
double Volumes[13][5][24][2];
string cur[13];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
   
   cur[0]="CADJPY";
   cur[1]="AUDJPY";
   cur[2]="CHFJPY";
   cur[3]="NZDUSD";
   cur[4]="EURJPY";
   cur[5]="EURCHF";
   cur[6]="EURGBP";
   cur[7]="USDCAD";
   cur[8]="AUDUSD";
   cur[9]="USDJPY";
   cur[10]="EURUSD";
   cur[11]="GBPUSD";
   cur[12]="USDCHF";
   
   int c,d,h;
   
   // reset array
   for (c=0;c<13;c++)
      for (d=0; d<5; d++)
         for (h =0; h<24; h++) 
            for (int n=0; n<2; n++)
               Volumes[c][d][h][n]=0;
       
  int handle=FileOpen(inFile, FILE_CSV|FILE_WRITE); 
  
  string t = cur[0];
  for (c=1; c<13; c++) t =  t + "     ,     " + cur[c]; 
  FileWrite(handle, t );  
    
  for (int i=0; i<Bars; i++) // for each bar
  {  
      h =  TimeHour(Time[i]);  
      d =  TimeDayOfWeek(Time[i])-1;
      
      for (c=0; c<13; c++)
      {     
         Volumes[c][d][h][0] += iVolume(cur[c],0,i);
         Volumes[c][d][h][1] ++;
      } // c
  } // i Bars
      for (d=0; d<5; d++)
         for (h =0; h<24; h++) 
         {
            string ss="";
            for (c=0;c<13;c++) ss = ss + (Volumes[c][d][h][0] /  Volumes[c][d][h][1]) + "   ,  " ; 
            FileWrite(handle,ss);      
         }
   
   FileClose(handle);
   
      
   return(0);
}
int start()
  {
   return(0);
  }
  
Comments