거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Twitter에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
라이브러리

CSV file reader for MQL5 - MetaTrader 5용 라이브러리

조회수:
7859
평가:
(21)
게시됨:
2019.02.23 17:01
업데이트됨:
2019.02.23 22:17
\MQL5\Scripts\
Sample.mq5 (3.59 KB) 조회
\MQL5\Files\
sample.zip (12.67 KB)
\MQL5\Include\
CsvReader.mqh (19.16 KB) 조회
MQL5 프리랜스 이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

Usage of the class

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);
 

Disadvantages of this class

  • this code is not very fast
  • handles only handle Unicode files at the moment. Single byte files are not a development priority.
  • It is possible this code reads a line and notices that EOF is reached at the end of the line.If possible do not  test with IsEnding(), use the return value  of the ReadLine functions instead. The return value will only return FILE_STATE_EOF after the next read. So all records will be processed.

Using the samples

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

Adaptive moving average - double smoothed

Normalized MACD - of averages Normalized MACD - of averages

Normalized MACD of averages

Intra-day ATR Intra-day ATR

Intra-day average true range

Intra-day Keltner channel Intra-day Keltner channel

Intra-day Keltner channel