I am trying to download the signal history using WebRequest function and the following function
bool SavePageFromInternet(string url, string filename){
string cookie=NULL,headers;
char post[],result[];
int res;
bool returnResponse = true;
ResetLastError();
int timeout=5000;
res=WebRequest("GET",url,cookie,NULL,timeout,post,0,result,headers);
//--- Checking errors if(res==-1){
Print("Error in WebRequest. Error code =",GetLastError());
returnResponse = false;
}
else{
PrintFormat("The file has been successfully loaded, File size = %d bytes.",ArraySize(result));
int filehandle=FileOpen(filename,FILE_WRITE|FILE_BIN);
if(filehandle!=INVALID_HANDLE){
FileWriteArray(filehandle,result,0,ArraySize(result));
FileClose(filehandle);
}
else {
Print("Error in FileOpen. Error code=",GetLastError());
returnResponse = false;
}
}
return returnResponse;
}
So I use as the url the address "https://www.mql5.com/en/signals/"+string(signal_number)+"/export/trading" as source, but the .csv file is not downloading. Instead, it saves the signal html page.
I checked the result of your download. The content of the file created is a html page, if you change the extention to html and open it in a browser, you will see the login page of MetaQuotes.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
I am trying to download the signal history using WebRequest function and the following function
So I use as the url the address "https://www.mql5.com/en/signals/"+string(signal_number)+"/export/trading" as source, but the .csv file is not downloading. Instead, it saves the signal html page.
Thus, how could I do it properly?