Your code:
int res = WebRequest("GET", NewsXML_URL, headers, timeout, NULL, 0, result, response_headers);
The WebRequest function has two versions, but neither uses eight parameters.
WebRequest
The function sends an HTTP request to a specified server. The function has two versions:
1. Sending simple requests of type "key=value" using the header Content-Type: application/x-www-form-urlencoded.
int WebRequest( const string method, // HTTP method const string url, // URL const string cookie, // cookie const string referer, // referer int timeout, // timeout const char &data[], // the array of the HTTP message body int data_size, // data[] array size in bytes char &result[], // an array containing server response data string &result_headers // headers of server response );
2. Sending a request of any type specifying the custom set of headers for a more flexible interaction with various Web services.
int WebRequest( const string method, // HTTP method const string url, // URL const string headers, // headers int timeout, // timeout const char &data[], // the array of the HTTP message body char &result[], // an array containing server response data string &result_headers // headers of server response );
Your code:
The WebRequest function has two versions, but neither uses eight parameters.
WebRequest
The function sends an HTTP request to a specified server. The function has two versions:
1. Sending simple requests of type "key=value" using the header Content-Type: application/x-www-form-urlencoded.
2. Sending a request of any type specifying the custom set of headers for a more flexible interaction with various Web services.
Thanks, but even after changing to 7 parameters, still not working:
bool IsHighImpactNewsUpcoming() { uchar result[4096]; // Fixed-size buffer for the response int timeout = 30000; // Timeout in milliseconds string response_headers = ""; // To store response headers // WebRequest function call with 7 parameters int res = WebRequest("GET", NewsXML_URL, NULL, timeout, NULL, 0, result); if (res == -1) { Print("Error fetching news XML: ", GetLastError()); return false; } if (res != 200) { Print("HTTP request failed, status code: ", res); return false; } // Convert response to string for processing string response = CharArrayToString(result, 0, ArraySize(result) - 1); // Process the response to check for high-impact news int pos = StringFind(response, "<event"); while (pos != -1) { string event = StringSubstr(response, pos, StringFind(response, "</event>", pos) - pos + 8); if (StringFind(event, "<currency>USD</currency>") != -1 && StringFind(event, "<impact>High</impact>") != -1) { Print("High-impact USD news found."); return true; } pos = StringFind(response, "<event", pos + 1); } Print("No high-impact USD news found."); return false; }
If you are still referring to the same error reported at the beginning of the topic, I ask that you take a closer look at the documentation... If you intend to use the version of the function with 7 parameters, you should inform something like this:
int res = WebRequest("GET", NewsXML_URL, headers, timeout, data, result, response_headers);
Data of type char, not uchar:
int WebRequest( const string method, // HTTP method const string url, // URL const string headers, // headers int timeout, // timeout const char &data[], // the array of the HTTP message body char &result[], // an array containing server response data string &result_headers // headers of server response );
See if the following article can help you with your project:
Using JSON Data API in your MQL projects
Sara Sabaghi, 2024.07.11 15:40
Imagine that you can use data that is not found in MetaTrader, you only get data from indicators by price analysis and technical analysis. Now imagine that you can access data that will take your trading power steps higher. You can multiply the power of the MetaTrader software if you mix the output of other software, macro analysis methods, and ultra-advanced tools through the API data. In this article, we will teach you how to use APIs and introduce useful and valuable API data services.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I have tried everything but i keep getting this error:
'WebRequest' - no one of the overloads can be applied to the function call
Please help..
Thanks