#property copyright "Copyright © 2010, sangmane."
#property link      "http://www.forexfactory.com"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red

extern string FileName = "data.csv";

double Line1[],Line2[];
string s[7][2000];
int rowTotal;
int init()
  {
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,Line1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,Line2);   
   IndicatorDigits(Digits+1);   

   int handle;

   string sx;
   string colname;
   int row=0,col=0;
   int maxcol=0, maxrow=0;
   handle=FileOpen(FileName,FILE_CSV|FILE_READ,",");
   if(handle>0)
   {
     while(True)
     {
       s[col][row] = FileReadString(handle);
       col++;
       if(FileIsLineEnding(handle))
       {
         if(maxcol==0) maxcol = col;
         col = 0;
         row++;
       }
       if(FileIsEnding(handle)) break;
     }
     FileClose(handle);
     rowTotal = row-1;
     Comment("There are ",row-1," rows, ",maxcol," cols.");
   }
   else
   {
     Comment("File "+FileName+" not found, the last error is ", GetLastError());
     return(false);
   }
        
   return(0);
  }

int start()
  { 
    for(int k = 1; k<=rowTotal; k++)
    {
      int i = iBarShift(NULL,0,StrToTime(s[0][k]),True);
      if(i>=0)
      {
        Line1[i] = StrToDouble(s[1][k]);
        Line2[i] = StrToDouble(s[2][k]);
      }
    }
    return(0);
  }
//+------------------------------------------------------------------+