0

I'm developing a program in MQL4 that's going to require a few snippets of data pulled from a specific web page.

How can I dump this into a .csv file every 5 minutes?

I'm stuck on how to am I going to go about this.

Structure

  1. Some pieces of data dumped from a .html page
  2. Plug into .csv file
  3. Read by MQL4
halfer
  • 19,824
  • 17
  • 99
  • 186
  • 3
    You may want to read **whathaveyoutried.com** & show some respect to the StackOverflow Community, which strongly encourages to post high quality questions, altogether with a **MCVE ( a Minimum-Complete-Verifiable-Example of code ) showing what-you-have-tried so far**. You may want to update your post, so as to meet this minimum reasonable level of quality & to show your will to respect other StackOverflow contributing members. They are professionals who love to answer good questions on MCVE-related issues. **Enjoy being StackOverflow Contributing Member & do support this Community Netiquette** – user3666197 Mar 05 '15 at 23:11

2 Answers2

3

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.
user3666197
  • 1
  • 6
  • 50
  • 92
jlee88my
  • 2,935
  • 21
  • 28
  • Looks like a good answer. However I generally recommend against adding meta-commentary in answers - most of the people reading this are not the original poster, and they don't want to read complaints. You have two options: you can add that kind of advice as a comment under the question, and/or you could vote to close as too broad (I have done that now). As you've discovered, low-effort questions can result in making a good answer and not even receiving a reply, but at least this will benefit other readers! – halfer May 10 '17 at 09:51
0

A Short Version

  1. Yes, possible -- via an MQL4-independent external process, being connected via ZeroMQ to the .ex4 due to control and synchronisation needs ( ZMQ has ports/wrappers for many production-grade environments, so ready to integrate MQL4 with whatever one needs
  2. Yes, possible -- Elementary, dear Watson... ( ref. #1, may be skipped, if needed )
  3. Yes, possible -- May be available in a process-to-process ( ref. #1 and #2 )

Check this and other MQL4/ZeroMQ posts on Stack Overflow

Another MQL4 Real-time output, being remote-logged and animated

Community
  • 1
  • 1
user3666197
  • 1
  • 6
  • 50
  • 92