New MetaTrader 5 Platform build 2265: DirectX functions for 3D visualization in MQL5 and symbol settings in Strategy Tester
Forum on trading, automated trading systems and testing trading strategies
SQLite in MQL5: New Features and Performance Testing
Renat Fatkhullin , 2019.12.07 09:24
In build 2265, we implemented regular functions for working with databases based on SQLite 3.30.1:
- DatabaseOpen
- Databaseclose
- DatabaseTableExists
- DatabaseExecute
- DatabasePrepare
- DatabaseRead
- DatabaseFinalize
- DatabaseTransactionBegin
- DatabaseTransactionCommit
- DatabaseTransactionRollback
- DatabaseColumnsCount
- DatabaseColumnName
- DatabaseColumnType
- DatabaseColumnSize
- DatabaseColumnText
- DatabaseColumnInteger
- DatabaseColumnLong
- DatabaseColumnDouble
- DatabaseColumnBlob
Bases can be stored both on disk and only in memory using the DATABASE_OPEN_MEMORY flag .
Wrapping massive inserts / changes in a DatabaseTransactionBegin / Commit / Rollback transaction speeds up operations hundreds
of times.
Windows 10 x64, Intel Xeon E5-2690 v3 @ 2.60GHz LLVM MQL5 --------------------------------------------------------------------------------- Test 1: 1000 INSERTs: 11572 8488 Test 2: 25000 INSERTs in a transaction: 59 60 Test 3: 25000 INSERTs into an indexed table: 102 105 Test 4: 100 SELECTs without an index: 142 150 Test 5: 100 SELECTs on a string comparison: 391 390 Test 6: Creating an index: 43 33 Test 7: 5000 SELECTs with an index: 385 307 Test 8: 1000 UPDATEs without an index: 58 54 Test 9: 25000 UPDATEs with an index: 161 165 Test 10: 25000 text UPDATEs with an index: 124 120 Test 11: INSERTs from a SELECT: 84 84 Test 12: DELETE without an index: 25 74 Test 13: DELETE with an index: 70 72 Test 14: A big INSERT after a big DELETE: 62 66 Test 15: A big DELETE followed by many small INSERTs: 33 33 Test 16: DROP TABLE: finished. 42 40
The speed in MQL5 is absolutely the same as in native C ++ with one of the best compilers. A benchmark package for playback is attached.
We also implemented the unique DatabaseReadBind function, which allows you to read records directly into the structure,
which simplifies and speeds up bulk operations.
Here is a simple example:
struct Person { int id; string name; int age; string address; double salary; }; //+------------------------------------------------------------------+ //| Test | //+------------------------------------------------------------------+ bool TestDB( string filename, int flags) { int db; //--- open db=DatabaseOpen(filename,flags); if (db== INVALID_HANDLE ) { Print ( "DB: " ,filename, " open failed with code " , GetLastError ()); return ( false ); } //--- create a table if (!DatabaseTableExists(db, "COMPANY" )) if (!DatabaseExecute(db, "CREATE TABLE COMPANY(" "ID INT PRIMARY KEY NOT NULL," "NAME TEXT NOT NULL," "AGE INT NOT NULL," "ADDRESS CHAR(50)," "SALARY REAL );" )) { Print ( "DB: " ,filename, " create table failed with code " , GetLastError ()); DatabaseClose(db); return ( false ); } //--- insert data if (!DatabaseExecute(db, "INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY) VALUES (1, 'Paul', 32, 'California', 20000.00 ); " "INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY) VALUES (2, 'Allen', 25, 'Texas', 15000.00 ); " "INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY) VALUES (3, 'Teddy', 23, 'Norway', 20000.00 );" "INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY) VALUES (4, 'Mark', 25, 'Rich-Mond ', 65000.00 );" )) { Print ( "DB: " ,filename, " insert failed with code " , GetLastError ()); DatabaseClose(db); return ( false ); } //--- prepare the request int request=DatabasePrepare(db, "SELECT * FROM COMPANY WHERE SALARY>15000" ); if (request== INVALID_HANDLE ) { Print ( "DB: " ,filename, " request failed with code " , GetLastError ()); DatabaseClose(db); return ( false ); } //--- выводим записи Person person; for ( int i= 0 ; DatabaseReadBind(request,person); i++) Print (i, ": " ,person.id, " " , person.name, " " ,person.age, " " ,person.address, " " ,person.salary); Print ( "" ); //--- close all DatabaseFinalize(request); DatabaseClose(db); return ( true ); } //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart () { TestDB( "test.sqlite" ,DATABASE_OPEN_READWRITE | DATABASE_OPEN_CREATE |DATABASE_OPEN_COMMON); } Output: 0 : 1 Paul 32 California 20000.0 1 : 3 Teddy 23 Norway 20000.0 2 : 4 Mark 25 Rich-Mond 65000.0
Forum on trading, automated trading systems and testing trading strategies
Renat Fatkhullin , 2019.12.07 08:28
Look at the new features of 3D graphics with examples in release 2265:
- / include / canvas - lots of functions for DirectX
- / experts / examples / Correlation Matrix 3D
- / experts / examples / Math 3D Morph
- / scripts / examples / Remnant 3D
Hi all,
I have seen that, with long file names of your EA, mine had 16 characters, and using the CCanvas class.
When a Create method is used, the ResourceCreate (...) may return with error 4018.
Be careful!
Bye Manuele
Great update and features. I appreciate that, but I want some more for UI designs.
We can change sub-window's caption bar width and font size from registry editor but can not modify sub-window's border thickness.
MT5's default sub-window border width might annoy users.
Please improve this.

- www.mql5.com
Great update and features. I appreciate that, but I want some more for UI designs.
We can change sub-window's caption bar width and font size from registry editor but can not modify sub-window's border thickness.
MT5's default sub-window border width might annoy users.
Please improve this.
Can you put what registry keys are for change subwindows width?
Can you put what registry keys are for change subwindows width?
HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
To display the trading history as positions, the terminal uses information about deals executed during the requested period. Only the positions closed within this period will be shown in history. If the position is still open or its close time does not fall within the selected interval, it will not be displayed in the history. Therefore, the total profit and commission in the 'positions' mode can differ from those in the 'orders/deals' history mode.
For example, you are viewing the past week history. During this period, 100 deals were executed, 98 of which participated in the opening and closing of 20 positions. The last two deals opened new positions, which have not been closed up to now. In this case, the history of deals contains 100 records and appropriate total values calculated based on these deals. When viewing the history as positions, you will see 20 records collected based on 98 deals. Only this data will be taken into account when calculating total values. If the broker charges entry deal fees, the final commission value in the deals history will differ from the commissions shown in the positions history, because the two last deals will be ignored in the latter case.
The new CCanvas3D class is an extension of the CCanvas custom graphics class. It is available in the \MQL5\Include\Canvas\ directory. The class features functions for rendering three-dimensional objects via DirectX API.
Detailed documentation for the new library will be published soon.
The following functions are available:
The following error codes have been added for function operations:
The property allows setting the type of chart which opens at the end of optimization, as well as program parameters for the X and Y axes.
The property only sets the default chart view. It can be changed manually at any time, using the context menu.
Custom settings for financial instruments
Now you can change settings of the main trading instrument, for which testing/optimization is performed. Almost all specification parameters can be overwritten: volumes, trading modes, margin requirements, execution mode and other settings. Thus, if you need to check an Expert Advisor under different conditions, there is no need to create a separate custom symbol and download its history. This can be done by changing standard symbol settings.

If the symbol specification is customized, the gear icon and the symbol icon are marked with an asterisk. This shows that custom parameters are used for the current test.Last settings/Expert Advisors/charts
Use the new context menu commands for fast testing or optimization setup. Choose the last used tester settings, recent charts or applications:
If appropriate compilers are installed on your PC, MetaEditor will detect them and add to settings. Optionally, you can specify paths to required components under the Compilers tab. From the same tab, you can download the components by clicking Install next to the appropriate field.
After that you can work with C/C++ and Python projects similarly to MQL5 programs.
There is no need to search for appropriate functions in a trader's room on the broker site. Fast navigation commands are available directly in terminals: users can switch to deposit and withdrawal pages from the Accounts and Trading sections: