Discussing the article: "Introduction to Connexus (Part 1): How to Use the WebRequest Function?"

 

Check out the new article: Introduction to Connexus (Part 1): How to Use the WebRequest Function?.

This article is the beginning of a series of developments for a library called “Connexus” to facilitate HTTP requests with MQL5. The goal of this project is to provide the end user with this opportunity and show how to use this helper library. I intended to make it as simple as possible to facilitate study and to provide the possibility for future developments.

The WebRequest function opens up a wide range of possibilities for integration with external services. From collecting financial data, which can be essential for automated trading decisions, to fully automating processes, this function allows EAs to interact directly with the web. This allows, for example, your trading robot to obtain real-time information from external sources, such as economic news or market data from other platforms. This data can be processed and used to automatically adjust your trading strategies, increasing both the accuracy and efficiency of your operations.

However, as will be demonstrated in the examples presented, using the WebRequest function may not be trivial. Sending an HTTP request might seem simple, but you will quickly encounter technical challenges, such as sending the correct headers, formatting JSON data, properly handling server responses, and even dealing with errors and exceptions that may occur during communication. These challenges will illustrate that, although powerful, the function requires a solid understanding of protocols and communication between systems, which can present a significant barrier for developers who are just starting to explore this area.

Author: joaopedrodev

 

Hello engineer joaopedrodev!

In any case, many thanks for this very interesting article.

But just a small problem. It is that, when I try to test in real conditions the code that you provided, namely, the "WebRequest" function with the POST method, the request arrives without problem on my server. Only, the data passed in parameters (

"{\"key1\":\"value1\",\"key2\":\"value2\"}" 

), they, they do not arrive on the server. Is it possible for you to have an idea to solve this? Thank you

Automatic translation applied by moderator. On the English forum, please write in English. Either use the automatic translation tool, or post in one of the other language forums.
 
J M #:

Hello engineer joaopedrodev!

In any case, many thanks for this very interesting article.

But just a small problem. It is that, when I try to test in real conditions the code that you provided, namely, the "WebRequest" function with the POST method, the request arrives without problem on my server. Only, the data passed in parameters (

), they, they do not arrive on the server. Is it possible for you to have an idea to solve this? Thank you

Automatic translation applied by moderator. On the English forum, please write in English. Either use the automatic translation tool, or post in one of the other language forums.

Hellow @J M

Make sure you are sending this data in the body of the request, so the server will correctly receive the data you want to send. I also ask that you use the latest version of the library that is attached in the last article Connexus Observer (Part 8): Adding a Request Observer

J M
J M
  • 2024.06.19
  • www.mql5.com
Trader's profile
 
I am also interested in the problem of using MT5 for DeFi. In general, I see that MT5, with all its attractiveness (namely, the ability to write tools with inbuilt tools) is not designed to work without brokers. it is brokers who pay for terminal support, while it is free for traders. Existing commercial projects, which allow to freely connect external resources, are quite expensive for their use. A trader's bread is usually irregular, so constant expenses are inappropriate for us. WebRequest() is not initially convenient for loading quotes via API, because APIs of different exchanges are different and are not optimised for WebRequest(). In fact, WebRequest() is a narrowly focused GET method, but in response comes a set of different types of data, which should be adapted (better) in .csv, structured for MT5. Python lists are much better suited for this than MQL arrays. But that's not the point, we need a symbol in the market overview that can load quotes from an external source (SQL for example). Through an EA it is cumbersome and requires connection to a left broker. So the free use of MT5 is still questionable, and WebRequest() is utopia.
 
Good Beer #:
But that's not the point, we need a symbol in the market overview that can load quotes from an external source (SQL, for example).

For this purpose, I created a custom symbol and a service that in the background updates its history via CustomRatesUpdate (via WebRequest) and CustomTicksAdd (via websocket) functions.

Good Beer #:
Through an EA it is cumbersome and requires a connection to a left broker.

Through EA is really cumbersome. Use a service. You do not need to connect to a "left" broker, get quotes directly from the provider where you plan to trade.

Good Beer #:
So free use of MT5 is still in question, and WebRequest() is utopia.

I use MT5 freely, no issues whatsoever. WebRequest is good for infrequent history updates and sending trade requests. For real time updates, use websockets.

 
That's right! Service! I didn't study them and forgot about them. Thank you!