How to check the web request is working or not?

 

Dear experienced traders


Do you how to check the web request is working or not? 


I'm test one news EA in same remote desktop VPS and same set but different broker. If it works well, the EA could stop open new positions during big news.

I find an issue that is, during the big news, some terminal stop open new positions and some terminal keep open new positions. 

I think it might because of web request is not working by some mistake. 


Do you how to check the web request is working or not? 

Do you have any experience about this kind of issue? 


* I can't find any history in journal for web request. 


Thank you in advance and best wishes,

Sky


 
int result = WebRequest(...);

Return Value

HTTP server response code or -1 for an error.

 
Marco vd Heijden:

Return Value

HTTP server response code or -1 for an error.

Thank you for your continuing support, Marco! 

Could you kindly teach me how to use this code for a market EA? 

Sorry that I'm not a coder.

 

Example:

void OnStart()
  {
   string cookie=NULL,headers;
   char   post[],result[];
   string url="https://finance.yahoo.com";
//--- To enable access to the server, you should add URL "https://finance.yahoo.com"
//--- to the list of allowed URLs (Main Menu->Tools->Options, tab "Expert Advisors"):
//--- Resetting the last error code
   ResetLastError();
//--- Downloading a html page from Yahoo Finance
   int res=WebRequest("GET",url,cookie,NULL,500,post,0,result,headers);
   if(res==-1)
     {
      Print("Error in WebRequest. Error code  =",GetLastError());
      //--- Perhaps the URL is not listed, display a message about the necessity to add the address
      MessageBox("Add the address '"+url+"' to the list of allowed URLs on tab 'Expert Advisors'","Error",MB_ICONINFORMATION);
     }
   else
     {
      if(res==200)
        {
         //--- Successful download
         PrintFormat("The file has been successfully downloaded, File size %d byte.",ArraySize(result));
         //PrintFormat("Server headers: %s",headers);
         //--- Saving the data to a file
         int filehandle=FileOpen("url.htm",FILE_WRITE|FILE_BIN);
         if(filehandle!=INVALID_HANDLE)
           {
            //--- Saving the contents of the result[] array to a file
            FileWriteArray(filehandle,result,0,ArraySize(result));
            //--- Closing the file
            FileClose(filehandle);
           }
         else
            Print("Error in FileOpen. Error code =",GetLastError());
        }
      else
         PrintFormat("Downloading '%s' failed, error code %d",url,res);
     }
  }
 
Marco vd Heijden:

Example:

Thank you so much, Marco. 

Is this a code for a script? 

Could you kindly teach me how can I use it in terminal? 

Sorry for my terrible knowledge about code...

 
Hi you can talk to someone over here: https://www.mql5.com/en/job
Trading applications for MetaTrader 5 to order
Trading applications for MetaTrader 5 to order
  • www.mql5.com
An Simple EA required for executing orders automatically Basic Ea with buy/sell, stop loss /Take profit . Simply executes when set to auto at current market price Either when i change it to buy or sell. But would like to include a pip counter and profit or loss in dollars Please contact me so that we can talk about the modification of the last...
 
Marco vd Heijden:
Hi you can talk to someone over here: https://www.mql5.com/en/job

Thank you so much, Marco! 

 

dear skye,

if there's a error retrieving infos with webrequest, the author of the ea has probably put an error code somewhere - check the status tab or the upper left corner of the chart the ea has been attached to.

if not, you could also private message him to make an update - it's quickly done, and more than relevant.

 
Icham Aidibe:

dear skye,

if there's a error retrieving infos with webrequest, the author of the ea has probably put an error code somewhere - check the status tab or the upper left corner of the chart the ea has been attached to.

if not, you could also private message him to make an update - it's quickly done, and more than relevant.

Dear Icham, thank you very much! 

Reason: