Download MetaTrader 5
To add comments, please log in or register
Publish your article. We will translate it into other languages!
Filip Pop
2390
Filip Pop 2014.08.13 13:12 

Hi everyone,

Has anyone worked with real-time data export from an MT4 EA/indicator to CSV files combined with Excel text data imports?

Normally this setup should work well, but every once in a while the Excel crashes, mentioning that the CSV files printed by the MT4 EA could not be found. This happens though the CSV files are never deleted, just over-written by the EA. Also, I also get -1 as the handle from time to time when opening the CSV files for writing into them.

I tried writing the CSV with FILE_SHARE_WRITE as the flag when opening the files, with no luck whatsoever, as no writing was actually done when opening the files that way.

Does anyone have any ideas on this? We've been dealing with this particular issue for several days now.


Phillip.

Import or export text (.txt or .csv) files
  • office.microsoft.com
There are two commonly used text file formats: Delimited text files (.txt), in which the TAB character (ASCII character code 009) typically separates each field of text. Comma separated values text files (.csv), in which the comma character (,) typically...
Rodrigo Malacarne
Moderator
9595
Rodrigo Malacarne 2014.08.13 13:23  
eabuilder:

Hi everyone,

Has anyone worked with real-time data export from an MT4 EA/indicator to CSV files combined with Excel text data imports?

Normally this setup should work well, but every once in a while the Excel crashes, mentioning that the CSV files printed by the MT4 EA could not be found. This happens though the CSV files are never deleted, just over-written by the EA. Also, I also get -1 as the handle from time to time when opening the CSV files for writing into them.

I tried writing the CSV with FILE_SHARE_WRITE as the flag when opening the files, with no luck whatsoever, as no writing was actually done when opening the files that way.

Does anyone have any ideas on this? We've been dealing with this particular issue for several days now.


Phillip.

Hi Phillip, please post MT4-related questions on the MT4 Forum.
MQL4: automated trading forum
  • forum.mql4.com
MQL4: automated trading forum
mantadiver
31
mantadiver 2015.07.15 06:37  
Filip Pop:

Hi everyone,

Has anyone worked with real-time data export from an MT4 EA/indicator to CSV files combined with Excel text data imports?

Normally this setup should work well, but every once in a while the Excel crashes, mentioning that the CSV files printed by the MT4 EA could not be found. This happens though the CSV files are never deleted, just over-written by the EA. Also, I also get -1 as the handle from time to time when opening the CSV files for writing into them.

I tried writing the CSV with FILE_SHARE_WRITE as the flag when opening the files, with no luck whatsoever, as no writing was actually done when opening the files that way.

Does anyone have any ideas on this? We've been dealing with this particular issue for several days now.


Phillip.

I have been having the same issues.

Excel set to auto import CSV file generated by indicator in MT4. Works fine and then Excel eventually throws an error stating "Excel cannot find the text file to refresh the external data range." Press OK and secondary message states Excel has stopped working, crashes and attempts to restart.

Cause 

When Metatrader updates the CSV the file size after FILE_WRITE changes to zero and then repopulates with the new data. If Excel tries to update whilst this is happening the crash occurs.

Solution 

Having spent many hours trying to overcome this from both the MQL end and Excel end, finally looked at the Excel helpfile (!).

Under "CSV Import" one of the first things mentioned is an add-in called "Excel Power Query". If you download this add-in from Microsoft and install it you will see a new tab in Excel called (unsurprisingly) POWER QUERY. After clearing out the old data connections and creating a new CSV data connection within Power Query the data will import as before. However now when there is a clash when Excel & MT4 attempt to access the CSV file at the same time you get a pop-up warning, press OK and excel continues without crashing.

Not a perfect solution but it's what I am using until someone more technical can offer a better solution.

/
To add comments, please log in or register