Personally I moved to the following design: data is downloaded by WebRequest in a helper expert (by schedule or upon request) and saved into a file. All copies of indicators interested in this data, read this file.
Stanislav Korotky:
Personally I moved to the following design: data is downloaded by WebRequest in a helper expert (by schedule or upon request) and saved into a file. All copies of indicators interested in this data, read this file.
Personally I moved to the following design: data is downloaded by WebRequest in a helper expert (by schedule or upon request) and saved into a file. All copies of indicators interested in this data, read this file.
Thanks, but that wont work in my case.
Isnt there anybody out there who knows how to make this?
you can make it through windows dll
Here is the answer.
//+------------------------------------------------------------------+ //| wininet.mqh | //| Dirk Hilger | //| Basic code taken from "gregspinner" @ mql5.com | //| https://www.stereotrader.net | //+------------------------------------------------------------------+ #property copyright "Copyright (C) 2016 by Doerk (Dirk Hilger)" #property link "www.stereotrader.net" #property strict #property version "1.00" /* This library contains functions for reading files from the internet without using the original WebRequest(). Sample #1: string content=InternetGetFile("http://www.myurl.net/myfile.txt"); Sample #2: string content=NULL; int errorcode=InternetGetFile("http://www.myurl.net/myfile.txt",content); */ //+------------------------------------------------------------------+ //+ Imports + //+------------------------------------------------------------------+ #import "Wininet.dll" int InternetOpenW(string, int, string, string, int); int InternetConnectW(int, string, int, string, string, int, int, int); int HttpRequestW(int, string, string, int, string, int, string, int); int InternetOpenUrlW(int, string, string, int, int, int); int InternetReadFile(int, uchar &sBuffer[], int, int& OneInt); int InternetCloseHandle(int); #import #import "kernel32.dll" int GetLastError(void); #import //+------------------------------------------------------------------+ //+ Main function which returns Windows error code + //+------------------------------------------------------------------+ int InternetGetFile(string url, string& content) { //--- Init content=NULL; //--- Create connection int httpconnect=0; int httprequest=0; int httpopen = Wininet::InternetOpenW("InternetGetFileMQL", 0, " "," ",0 ); int e=kernel32::GetLastError(); if (e==0) { httpconnect = Wininet::InternetConnectW(httpopen, " ", 80, "", "", 3, 0, 1); e=kernel32::GetLastError(); if (e==0) { httprequest = Wininet::InternetOpenUrlW(httpopen,url, NULL, 0, 0, 0); e=kernel32::GetLastError(); if (e==0) { //--- Define buffers uchar ch[512]; string temp=""; //--- Retrieve data from file int cnt=0; while(Wininet::InternetReadFile(httprequest,ch,512,cnt)) { //e=kernel32::GetLastError(); if(cnt<=0) break; temp=temp+CharArrayToString(ch,0,cnt); } //--- Store result content=temp; } } } //--- Close connection if (httprequest > 0) InternetCloseHandle(httprequest); if (httpconnect > 0) InternetCloseHandle(httpconnect); if (httpopen > 0) InternetCloseHandle(httpopen); //--- Get out and return error code return(e); } //+------------------------------------------------------------------+ //+ Macro function which returns content directly + //+------------------------------------------------------------------+ string InternetGetFile(string url) { string content=NULL; int e=InternetGetFile(url,content); return content; }
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hey there,
WebRequest() isn't working with indicators, for whatever reason, therefore I need a possibility to load a file from a http or ftp. The samples I found to work with wininet.dll dont seem to work, any of them produces errors and not results.
I am not that familiar with internet stuff, so I am asking if there is or if someone has a simple function sample that I could use for my purpose. It the should be somehow simple like
string filecontent = ReadFromHttp("www.myurl.net/myfile.txt");
Anyone out there who could help me?
Thank you in advance
Doerk