1. Set up an array of column descriptions in an MqlParam array.
CCsvReader infile; MqlParam example_column_desc[] = { { TYPE_STRING, 0, 0.0, "symbol" }, // 1. field is string { TYPE_DOUBLE, 0, 0.0, "contractsize" }, // 2. field is double { TYPE_DATETIME, 0, 0.0, "expiration" } // 3. field is datetime }; infile.FieldDesc(example_column_desc);
2. Open the file with the Open() function
infile.Open(InpFileName, FILE_READ);
2a. When the file has a header and your are not interested in the contents of the headerline skip it with Readline(void).
infile.ReadLine();
3. With ReadLine(MqlParam arr) a MqlParam array is filled with values of one text line of the CSV file.
MqlParam dataline[]; int fieldsread; fieldsread = infile.ReadLine(dataline);
I provided a LibreCalc spreadsheet with 3 sheets. It is a sample that calculate some orders of a pyramid system. The first sheet as exported as CSV file with "Save As...". Use format CSV file with Tab as separator and to use Unicode. Put the CSV file in your <MQL5>\Files directory. The script Sample.mq5 will read the CSV file and print the values of the CSV file.
Adaptive moving average - double smoothed
Adaptive moving average - double smoothed
Normalized MACD - of averages
Normalized MACD of averages