Not plotting data from CSV File

 

Hi there,


I am new to MQL4, my first ever indicator program, which I coded so far.

I want to plot some values from CSV File. The format of CSV file is -

3/20/2017 0:00, 120

3/20/2017 0:05, 125

3/20/2017 0:10, 128

and so on

I want to plot the values wrt the candle/bar. All is working fine, I have tested it at various points using Print, only problem is in the

code which is used to load the Buffer. I am unable to understand.

The Code is -

#property  indicator_separate_window
#property  indicator_buffers 1
#property  indicator_color1  Red
#property  indicator_width1  1

string   FileName         = "dataFile.csv";

double     buffer0[];
datetime   dt[9999];
double     val[9999];
string     arr[9999];    // added to accomplish format conversion
int c;
int init()  
{
  SetIndexBuffer(0,buffer0);
  SetIndexStyle(0,DRAW_LINE,STYLE_SOLID);
  //SetIndexDrawBegin(0,0);
  IndicatorShortName("Plotting : "+FileName);
  return(0);
}

int start()  
{
  //Print("File names : "); 
  int h = FileOpen(FileName, FILE_CSV|FILE_READ,',');
  if(h!=INVALID_HANDLE)
  {
      if (h==0) {
         Comment("File "+FileName+" not found.");
         return(0);
      }  

      for (int c=0; !FileIsEnding(h) && c<9999; c++)  {
         
         if (FileIsEnding(h))  break;
      
         dt[c]= FileReadDatetime(h);
         val[c]=FileReadNumber(h);
      
      }
      FileClose(h);
      
      // Passing the data for plotting
       //Here is the main problem
      c--;
      for (int j=0; j<=Bars; j++)  {
         while(Time[j] < dt[c]) c--;
            if (c >= 0) 
               buffer0[j] = val[c];
            Print("Time    : ", Time[j]);
      }
   }
   else
   {
      Print("File Not Found");  
   }
   return(0);   
}
 
The problem is solved. There was a little confusion in understanding the logic to transfer the data to buffer.
Reason: