Discussing the article: "Market Replay: Unity Is Strength (II)"

 

Check out the new article: Market Replay: Unity Is Strength (II).

Until now, the application being developed as part of this series of articles has focused exclusively on simulating the graphical part. However, to obtain a more complete system in which we can test the Expert Advisor within the replay/simulation service, we also need to simulate the trading server. You'll notice that this simulation will include only the most essential elements. Nevertheless, you, dear reader, will be able to fill in the missing parts. Since these additional components don't affect what I want to show, we already have more than enough to implement what we have in mind.

First, we’ll prepare the database so that we can insert new records, update existing ones, and search for the records we need. This is the starting point, since the database will provide the interaction layer between all the applications that will be involved in simulating the operation of a real server. Please note this difference. I am not saying that we are going to create a simulated server. We will create a mechanism capable of modeling what would happen on the server in a real trading situation.

This mechanism will allow us to run simulations with positions and pending orders. Although I haven't yet explained how the pending order system will work, it is actually already included in the position indicator's code. All that is needed is to adapt the code, but the operation of the pending order system will be discussed later. Let's start by creating a database. The following figure essentially shows the data we need to store in the database.

Obviously, each of these data elements will correspond to a separate column, and the columns may be distributed across one or more tables. However, for educational purposes, I can combine all the columns into a single table. Before combining all the data into a single table, I wondered whether it really made sense to prepare these values in the Expert Advisor. The thing is, I want to prevent the user from submitting a market order while the replay/simulation system is paused. The most appropriate place to check whether the replay/simulation system is paused is the control indicator.


Author: Daniel Jose