How can I count the same data

 

Hello,

this is data exported to excel:

This is code for retrieved data: 

   int h = FileOpen("OrdersReport.csv", FILE_CSV|FILE_READ,'~');
  if (h==0)   Comment("File "+"OrdersReport.csv"+" not found.");

  // First pass loads data from file into arrays dt, val   (i.e. date/time, and value)
  for (int c=0; !FileIsEnding(h) && c<9999; c++)  {

    // The original code (below) assumes that data will be in the format [yyyy.mm.dd,value] .....  
    //    dt[c]  = StrToTime(FileReadString(h));
    //    if (FileIsEnding(h)) break;
    //    val[c] = StrToDouble(FileReadString(h));

    // I've adapted it to accommodate your format [dd.mm.yyyy,value] .....
    string tmp = FileReadString(h);
    if (FileIsEnding(h))  break;
    StrToStringArray(tmp,arr,",");
    dt[c]  = StrToTime(StringSubstr(arr[0],6,4)+"."+StringSubstr(arr[0],3,2)+"."+StringSubstr(arr[0],0,2));
    val[c] = StrToNumber(arr[1]);
//    if (c>0)  log(c,DateToStr(dt[c]),NumberToStr(val[c],"RT-3.5"));    // debugging only

      Print(tmp);
    // ============================================================================
  }
  FileClose(h);
  // Second pass re-synchs data from dt, val arrays onto chart timeframe, and plots them accordingly
  c--;
  for (int i=0; i<=Bars; i++)  {
    while(Time[i] < dt[c]) c--;
    if (c >= 0) buffer0[i] = val[c];
//    if (i<30) log(i,DateToStr(Time[i]),c,DateToStr(dt[c]),val[c],buffer0[i]);    // debugging only
  }
  

If you can see now I want count USDJPY Count=1 and EURUSD count=2
Both has MagicNumber so I can use also this for count, but must be desplayed what is counting. like EURUSD(currency), 1111(MagicNumber), 2(count)

 

Your image shows values separated by commas. Why are you reading the entire line and separating and converting the values yourself?

Write a structure and add a method to read an individual line into self. Then wile the file isn't ending, add an element to your array.

Reason: