Discussing the article: "Developing a multi-currency Expert Advisor (Part 10): Creating objects from a string"

 

Check out the new article: Developing a multi-currency Expert Advisor (Part 10): Creating objects from a string.

The EA development plan includes several stages with intermediate results being saved in the database. They can only be retrieved from there again as strings or numbers, not objects. So we need a way to recreate the desired objects in the EA from the strings read from the database.

In the previous article, I have outlined a general plan for developing the EA, which includes several stages. Each stage generates a certain amount of information to be used in the stages that follow. I decided to save this information in a database and created a table in it, in which we can place the results of single passes of the strategy tester for various EAs.

In order to be able to use this information in the next steps, we need to have some way of creating the necessary objects (trading strategies, their groups and EAs) from the information stored in the database. There is no option to save objects directly to the database. The best thing that can be suggested is to convert all the properties of objects into a string, save it in the database, then read this string from the database and create the required object from it.

Creating an object from a string can be implemented in different ways. For example, we can create an object of the desired class with default parameters, and then use a special method or function to parse the string read from the database and assign the corresponding values to the object properties. Alternatively, we can create an additional object constructor that will accept only one string as an input. This string will be parsed into parts inside the constructor and the corresponding values will be assigned to the object properties there. To understand which option is better, let's first look at how we store information about objects in the database.

Author: Yuriy Bykov

 

Yuri hello. Thank you for the interesting series of articles.

Yuri, could you post the strategy file with which you tested the Expert Advisor from the current article? This is the one you got the screenshot at the bottom of the article. If it is posted somewhere, please tell me where, I have not found it under other articles. Should I put it in the folder C:\Users\Admin/AppData\Roaming\MetaQuotes\Terminal\Common\Files or in the terminal folder? I want to see if I get the same results in the terminal as in your screenshot.

 

Hello Victor.

This file can be obtained by running the EA optimisation with one strategy instance and after finishing it, saving its results first in XML and then saving it to CSV from Excel. This was explained in Part 6.