Discussing the article: "Market Simulation (Part 07): Sockets (I)"

 

Check out the new article: Market Simulation (Part 07): Sockets (I).

Sockets. Do you know what they are for or how to use them in MetaTrader 5? If the answer is no, let's start by studying them. In today's article, we'll cover the basics. Since there are several ways to do the same thing, and we are always interested in the result, I want to show that there is indeed a simple way to transfer data from MetaTrader 5 to other programs, such as Excel. However, the main idea is not to transfer data from MetaTrader 5 to Excel, but the opposite, that is, to transfer data from Excel or any other program to MetaTrader 5.

In the previous article, Market Simulation (Part 06): Transferring Information from MetaTrader 5 to Excel, I explained how, using simple means and pure MQL5, you can transfer quote data from MetaTrader 5 into Excel. Of course, that was only a very basic example, whose purpose was to be as didactic as possible. However, you may have noticed that the quote updates were not happening in real time. Still, the knowledge presented in the previous article aims to demonstrate something else that we will actually need to do.

But since there are several ways to achieve the same thing, and what really matters to us is always the result, I wanted to show that yes, there is a simple way to transfer data from MetaTrader 5 into other programs, such as Excel. However, the main idea is not to transfer data from MetaTrader 5 to Excel, but the opposite, that is, to transfer data from Excel or any other program to MetaTrader 5.

There are several ways to accomplish this. Some are simpler, others more elaborate. Some can do this in real time, while others introduce a slight delay. But what matters is: Can we control MetaTrader 5, or some type of application running within it, using external data? This kind of question may seem trivial, but it opens up important possibilities. For example, you could conduct some sort of study or analysis using an external program specifically designed for such tasks. You could define points of interest in terms of price or quotation and place such data somewhere where an application (an Expert Advisor, Service, Script, or even an Indicator) can use it. This can then provide us with signals directly on the chart or, in the case of an Expert Advisor, assist us in decision-making.

At this point, only your imagination and your level of interest will limit what can be done and how far you can go. But before we move on to developing something we actually need for the Replay/Simulator, I want to show something else. For that, these concepts, ideas, and possibilities need to be presented so that you can truly understand what will be developed and implemented later and thus make the best possible use of all this knowledge.

What I will show in this article is a step forward on the same topic covered previously. Because, as I said, the method demonstrated earlier does not allow us to send data in real time. Although that is already sufficient for what we need in the replay/simulator, it does not meet our needs if we want information in real time.


Author: Daniel Jose