Topic: EA generator data import fails with big time horizon

Hello,

to describe my problem I'll talk about what I did first.
1. Download Data Export.mq5 from EA Studio Data tab.
2. Import script in Metatrader5
3. Apply script to EURUSD
4. Copy exported data in separate folder in EA generator.

When I apply the script with default settings it works with the generator.

But when I set the maximum count of bars to unlimited and the start limitation to 1989 I get the following error when I start the generator. When I import the data into EA Studio there are no errors and everything looks good.
Do you have any idea on how to fix this?

I don't want to compromise on the time horizon.
Other users have reported that they use older data than what I have. 
So I don't realy understand where I did go wrong.

C:\Users\PC\Desktop\EA Generator>node .\bin\gen.js --symbol EURUSD --period M30 --data_file = ./data/IC_Markets/EURUSD30.json
                        ..:: Express Generator v2.34 ::..
SyntaxError: Unexpected token � in JSON at position 0
    at JSON.parse (<anonymous>)
    at Object.<anonymous> (C:\Users\PC\Desktop\EA Generator\bin\gen.js:59:25)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47

Re: EA generator data import fails with big time horizon

I took a look in the code of gen.js and noticed that the program expects UTF8 encoding.
After changing the encoding from UTF16 to UTF8 it works.

It looks like that UTF8 encoding is neither enforced in the data export script nor in gen.js.
I've modified the SaveFile function inside the data export script but not tested yet since it takes a couple of hours for the export. Maybe it's also necessary to change FILE_TXT -> FILE_ANSI.

void SaveFile(const string fileName, const string data)
  {
   ResetLastError();
   const int file_handle = FileOpen(fileName, FILE_WRITE | FILE_TXT, '\t', CP_UTF8);
   if(file_handle != INVALID_HANDLE)
     {
      FileWrite(file_handle, data);
      FileClose(file_handle);
     }
  }