I am using this article to make an automated optimization process for my EA.
https://www.mql5.com/en/articles/4917
While the author exports the optimization results as an xml file which is read by the “Working Instance”, I am taking a different approach. My EA will log all deals into a database at the end of each pass.
The problem is I want this database to be accessible by both the Working Instance and the Optimiser Instance.
Can sqlite files be stored in the common folder for multiple terminals to read / write ?
Can a single database be accessed at the same time from multiple terminals?
Any suggestions for my approach?
I have never use SQLite with MetaTrader, but the SQLite engine can support concurrent access to a degree, if done properly.
Read up on the following Article, which also includes a section on saveing optimisation results to be used afterwards:
![SQLite: Native handling of SQL databases in MQL5 SQLite: Native handling of SQL databases in MQL5](https://c.mql5.com/36/47/sqlite-native-handling-of-sql-databases.jpg)
- www.mql5.com
Followup: Even if MetaTrader does not allow the SQLite file to be placed in a common area, you can still use a hard-link at the various locations, so as to point to a common location, and have the database be shared and accessible to both the Strategy Tester and the working EA.
Followup: Even if MetaTrader does not allow the SQLite file to be placed in a common area, you can still use a hard-link at the various locations, so as to point to a common location, and have the database be shared and accessible to both the Strategy Tester and the working EA.
Thank you very much! I missed a very obvious piece of information in the DatabaseOpen() doc...
https://www.mql5.com/en/docs/database/databaseopen
there is a DATABASE_OPEN_COMMON flag...
I did some testing and found that databases stored in common can be opened, read, and written to simultaneously by separate terminals. Although I am not sure how safe it would be to read / write to the same table. That is why I will be modifying different tables from each terminal.
![Documentation on MQL5: Working with databases / DatabaseOpen Documentation on MQL5: Working with databases / DatabaseOpen](https://c.mql5.com/36/47/documentation-on-mql5-working-with.png)
- www.mql5.com
Thank you very much! I missed a very obvious piece of information in the DatabaseOpen() doc...
https://www.mql5.com/en/docs/database/databaseopen
there is a DATABASE_OPEN_COMMON flag...
I did some testing and found that databases stored in common can be opened, read, and written to simultaneously by separate terminals. Although I am not sure how safe it would be to read / write to the same table. That is why I will be modifying different tables from each terminal.
Thank you very much! I missed a very obvious piece of information in the DatabaseOpen() doc...
https://www.mql5.com/en/docs/database/databaseopen
there is a DATABASE_OPEN_COMMON flag...
I did some testing and found that databases stored in common can be opened, read, and written to simultaneously by separate terminals. Although I am not sure how safe it would be to read / write to the same table. That is why I will be modifying different tables from each terminal.
@emerson2102 thank you for your comment. The DATABASE_OPEN_COMMON is to define which folder the file is created (see below), but it does not say it supports concurrency. Can you please share if your experience in using same db file simultaneously? Thanks
DATABASE_OPEN_COMMON | The file is in the common folder of all terminals |
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am using this article to make an automated optimization process for my EA.
https://www.mql5.com/en/articles/4917
While the author exports the optimization results as an xml file which is read by the “Working Instance”, I am taking a different approach. My EA will log all deals into a database at the end of each pass.
The problem is I want this database to be accessible by both the Working Instance and the Optimiser Instance.
Can sqlite files be stored in the common folder for multiple terminals to read / write ?
Can a single database be accessed at the same time from multiple terminals?
Any suggestions for my approach?