4

I am looking for a simple function which is able to read a text or binary file from the internet into a string variable.

It´s unbelievable that I could not find anything in the web, just low level descriptions of all the WinInet functions and useless samples, that do not work at all, at the MQL-forums.

What I need is a function like:

string buffer = ReadTextFileFromWeb( "www.myurl.net/textfile.txt" );

No more, no less. I am not very familiar with internet programming stuff at all, but I am sure there is anybody out there who is able to present the reason just like that.

The code will be used in MQL4/MQL5. I know that there is already a WebRequest() function which works, but it is restricted to expert advisors and cannot be used in Custom Indicator type of code.

I need this solution to load data into a custom indicator.

user3666197
  • 1
  • 6
  • 50
  • 92
Doerk
  • 71
  • 8
  • Let me ask about the real use-case **cardinal design features** / perfomance envelope: **a) expected length of a `string`** expected to load? **b) is the `string` rather constant or variable** throughout the `Custom Indicator` life-cycle, i.e. does it change at all, or in a per-tick manner or in a "just from time to time" manner? – user3666197 Aug 20 '16 at 18:03
  • Btw. there are even more restrictions for **`WebRequest()`** besides it's ban from being run in `Custom Indicator`. Anyway, there are several ways, how to attack the target, so do not worry, it is doable. Kindly update a few details about performance envelope & will be glad to recommend a feasible solution for given metrics. – user3666197 Aug 20 '16 at 18:09

1 Answers1

2

Go get this on github https://github.com/sergeylukin/mql4-http

//For MT4 Add HTTP Access
#include <mql4-http.mqh>

string URLr = "www.myurl.net/textfile.txt";
Print("URLr return is: ", URLr);

For MT5 you are on your own.

The above dose not have the issues that WebRequest() has. Or I have not seen it have any issues. I use it all the time in a lot of EA and never had a chart lockup or have a issue.

user10078199
  • 141
  • 2
  • 8