Discussing the article: "Market Simulation: Position View (VI)"

 

Check out the new article: Market Simulation: Position View (VI).

In this article, we will implement a number of improvements to ensure that the position indicator accurately reflects the actual state on the trading server in terms of open positions and their current state. I should point out that the applications shown here are in no way intended to replace any of the elements available in MetaTrader 5. They should also not be used without due caution and a balanced approach, since their purpose is to provide educational code—that is, code intended solely for learning how the system works. The reason I call this code “educational” is that, in some cases, using messages is not the best way to implement certain functions.

In the previous article, Market Simulation: Position View (V), we explained how to obtain the data needed to understand what is happening in the application. This will allow us to implement the system using the OnTradeTransaction function. There, we showed only how to do this in the Expert Advisor. After studying that data and the Expert Advisor, dear reader, you probably became very confused and started to doubt how practical this really is. A little skepticism will not hurt. It is also helpful—and even advisable—to have some doubts when we encounter something completely new.

Thus, in this article, we will take the first steps toward understanding the data presented in the previous article. Since the material we are covering may seem a little confusing at first glance, I want you to take your time later to go through this article and run some tests to try to understand what will be explained. Under no circumstances should you apply the material discussed in this article to a real account without fully understanding what is happening, as there is a high probability of incurring losses and making mistakes when interpreting the data displayed on the chart, which could result in an extremely adverse experience of using the system we are developing.

Once again: do not use the system we are going to create without properly understanding it. To that end, actively experiment and examine the code, since its purpose here is to be as clear and educational as possible. In this case, efficiency is just a minor detail. The main requirement is that the code should be as simple as possible so that everyone can understand what is happening.


Author: Daniel Jose