Prices in DoEasy library Updating tick series in real time, preparation for working with Depth of Market

I Concept:

I have created the tick data collection of all symbols used in the program. The library is able to obtain the required amount of tick data for each of the symbols used by the program and stores all of them in the collection of tick data. The tick data collection allows finding any required tick object and receiving its data. We are able to sort out the lists for conducting statistical research. However, new ticks are not entered into the tick database when new ticks arrive for symbols. In this article, I am going to implement this feature.

Each new tick will increase the number of stored objects in the collection. To limit their number, as well as the number of used memory, let's introduce a constant allowing us to set the maximum possible number of ticks stored in the library database for one instrument. This will protect us from running out of memory. If many symbols are used in the program and the database already contains a sufficient number of ticks, the library automatically removes the necessary amount of the oldest ticks. Thus, we will always have the specified number of ticks for the instrument. The default number is 200,000. This number should be sufficient for conducting statistical research for about the last two days. In any case, the maximum number of ticks stored in the collection for a single instrument can always be changed if necessary.

Also, I will start preparations for working with the Depth of Market (DOM). I am going to introduce the ability to subscribe to the DOM broadcast in the symbol object class. In the next articles, I will start implementing the functionality for working with DOM.

When a new tick arrives to the current symbol, we need to add it to the MqlTick structure. A new tick object is created based on the structure and added to the tick series list stored in the collection together with the lists of other symbols. However, we cannot obtain ticks for other symbols in the program's OnTick() handler as the handler is activated when a new tick arrives to the current symbol. Therefore, in order to obtain new ticks on other used symbols, we need to control them in the library timer using the previously created "New tick" class object. To do this, we need yet another library timer, in which ticks for all instruments except the current one are tracked for updating the lists of tick data of these instruments.


Comments