Since your Question is so general (not specific coding issue), and it is too wide. I will offer a generalize answer to point you at the right direction. You need to do your own research.
PART 1 - Schedule an Event
- In your EA, in the OnInit(); create a timer with
EventSetTimer(5*60)
.
- That will trigger the event OnTimer() event. 5*60 = 5 minutes.
- In that
OnTimer()
event, call your download program (see Part 2)
PART 2 - DOWNLOAD HTML
You can achieve this without using 3rd-party DLLs. The built-in Windows Wininet.DLL
has the right APIs for this:
import "wininet.dll" //Put a # in-front of import
int InternetAttemptConnect (int x);
int InternetOpenW(string sAgent, int lAccessType,
string sProxyName = "", string sProxyBypass = "",
int lFlags = 0);
int InternetOpenUrlW(int hInternetSession, string sUrl,
string sHeaders = "", int lHeadersLength = 0,
int lFlags = 0, int lContext = 0);
int InternetReadFile(int hFile, int& sBuffer[], int lNumBytesToRead,
int& lNumberOfBytesRead[]);
int InternetCloseHandle(int hInet);
import //Put a # in-front of import
That should get your started on the download part (do some research on your own).
- First is to create a browser session using the
OpenW
, then open the URL with the OpenURLW
, then read the content of the page with the ReadFile API; and finally, close the session with CloseHandle
.
- Once you have the HTML in a string variable within your MT4 code, all you need is to massage it the way you want it.
PART 3 - To Write To a .CSV
To perform File write operation, you are looking at the FileOpen()
, FileWriteString()
and FileClose()
MQL4 functions.
PART 4 - To Read the .CSV
- To read the CSV file, it is as simple as using the
FileReadString()
.
- You can split the string into CSV by using the
StringSplit()
function.