New MetaTrader 5 Platform build 2265: DirectX functions for 3D visualization in MQL5 and symbol settings in Strategy Tester

The MetaTrader 5 platform update will be released on Friday, December the 6th, 2019. The new version features the following changes:

  1. Terminal: More columns have become available in Market Watch. The main section now features 40 additional symbol parameters, which were previously available only under the Details tab.

  2. Terminal: Added highlighting of the currently connected account and the current server in the Navigator. The function will be useful if you have multiple accounts with different brokers.

  3. Terminal: Updated frame design for charts. Frames have become smaller and thus more space is now available for useful information.

  4. Terminal: Modified algorithm for calculating trading totals when displaying the trading history as positions. The values are now calculated based on actual records.

    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.

  5. Terminal: Implemented faster launching of MQL5 programs.
  6. Terminal: New /beta key has been added for the terminal installation file, which allows downloading the beta version. In normal mode, the release version should be installed first, which can then be updated till a beta version. By skipping this step, you can save time and traffic. Installation start example:
    C:\mt5setup.exe /beta
  7. Terminal: Fixed display of margin requirements for instruments with the "Exchange Stocks" type.
  8. Terminal: Accelerated operation of all platform components through the use of the Clang/LLVM compiler. In some cases compilation is 20% faster.
  9. MQL5: Added new DirectX 11 functions and shaders for 3D visualization. Now powerful three-dimensional graphics can be created directly in MQL5.

    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.

    • Create — creates a scene.
    • Attach — binds a scene to a chart.
    • Destroy — destroys a scene.
    • ObjectAdd — adds to the scene a descendant object inherited from the base CDXObject class.
    • Render — the full render loop, with buffer clearing and rendering of all CDXObject, added via the ObjectAdd method.
    • RenderBegin — starts scene rendering, fills the render buffer with the specified color (if DX_CLEAR_COLOR flag is set) and the depth buffers (when using DX_CLEAR_DEPTH), as well as sets the DXInputScene scene buffer for default shaders.
    • RenderEnd — completes scene rendering and receives a result to an internal buffer. If redraw==true, displays the image on the chart, on which it is running.
    • ViewMatrixGet — receives a view matrix.
    • ViewMatrixSet — sets a view matrix. The matrix is not compatible with ViewPositionSet, ViewRotationSet, ViewTargetSet and ViewUpDirectionsSet methods.
    • ViewPositionSet — sets camera position.
    • ViewRotationSet — sets camera rotation matrix.
    • ViewTargetSet — sets the point the camera is pointing at. Together with ViewUpDirectionsSet, it is an alternative to ViewRotationSet.
    • ViewUpDirectionsSet — sets the vertical position of the camera. Together with ViewTargetSet, it is an alternative to ViewRotationSet.
    • ProjectionMatrixGet — receives a projection matrix.
    • ProjectionMatrixSet — sets a projection matrix.

    Detailed documentation for the new library will be published soon.

  10. MQL5: Added support for operations with SQLite databases directly from MQL5. This enables easy execution of SQL queries without creating complex instructions. The internal operation is implemented by the new standard library extension.

    The following functions are available:

    • DatabaseOpen — opens or creates a database in the specified file
    • DatabaseClose — closes a database
    • DatabaseTableExists — checks if there is a table in the database
    • DatabaseExecute — executes a query to the specified database
    • DatabasePrepare — creates a query handle, which can be further executed using DatabaseRead()
    • DatabaseRead — jumps to the next record in the query result
    • DatabaseFinalize — deletes a query which was created in DatabasePrepare()
    • DatabaseTransactionBegin — starts the execution of a transaction
    • DatabaseTransactionCommit — completes the execution of a transaction
    • DatabaseTransactionRollback — rolls back a transaction
    • DatabaseColumnsCount — receives the number of fields in a query
    • DatabaseColumnName — receives field name by number
    • DatabaseColumnType — receives field type by number
    • DatabaseColumnSize — receives field size in bytes
    • DatabaseColumnText — receives a string value of a field from the current record
    • DatabaseColumnInteger —  receives an int value from the current record
    • DatabaseColumnLong — receives a long value from the current record
    • DatabaseColumnDouble — receives a double value from the current record
    • DatabaseColumnBlob — receives an array of field values from the current record

    The following error codes have been added for function operations:

    • ERR_MQL_DATABASE_INTERNAL (5120) — internal database error
    • ERR_MQL_DATABASE_INVALID_HANDLE (5121) — invalid database handle
    • ERR_MQL_DATABASE_TOO_MANY_OBJECTS (5122) — maximum number of Database objects exceeded
    • ERR_MQL_DATABASE_CONNECT (5123) — database connection error
    • ERR_MQL_DATABASE_EXECUTE (5124) — request execution error
    • ERR_MQL_DATABASE_PREPARE (5125) — request creation error
    • ERR_MQL_DATABASE_NO_MORE_DATA (5126) — no more data to read
    • ERR_MQL_DATABASE_STEP (5127) — error moving to the next query record
    • ERR_MQL_DATABASE_NOT_READY (5128) — data to read query results is not yet ready
    • ERR_MQL_DATABASE_BIND_PARAMETERS (5129) — SQL query auto-substitution error

  11. MQL5: Added new property of MQL5 programs, which enables the selection of a default visualization method.
    #property optimization_chart_mode "3d,InpX,InpY"
    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.

  12. MQL5: New MathArctan2 function. Returns the radian value of the angle, the tangent of which is equal to the ratio of the two specified numbers.
    double  MathArctan2(
       double  y      // the y coordinate of the point
       double  x      // the x coordinate of the point
  13. MQL5: We have performed the general optimization of programs to improve performance and reduce resource consumption.
  14. MQL5: Added examples of math calculations which can be performed in the strategy tester. They are available under the \MQL5\Experts\Examples\Math 3D\ directory.
  15. MQL5: Introduced tighter control of namespaces.
  16. MQL5: Added loading of linked libraries when using .NET libraries in MQL5 programs. If the used .NET library requires other libraries for operation, the compiler will try to download required libraries automatically from \MQL5\Libraries.
  17. MQL5: Fixed time operations in the MetaTrader module for Python integration. Now all output data use the time of the trading server to which the terminal is connected.
  18. Tester: A plethora of new features and improvements:

    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:

  19. MetaEditor: Added ability to work with C/C++ and Python projects directly from MetaEditor. Now, multi-lingual projects can be managed using the built-in editor.

    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.

  20. MetaEditor: Added support for sub-projects inside the Shared Projects directory intended for shared project development via MQL5 Storage. Previously, only single projects could be created at the top level.
  21. MetaEditor: Built-in debugger updates.
  22. MetaEditor: Fixed addition of a function header when using a code styler.
  23. MetaEditor: 'Jump to previous/next cursor position' commands are now available not only in the View menu, but also on the toolbar.
  24. MetaEditor: Spaces can now be used in project names.
  25. Android: Added ability to quickly switch to deposit/withdrawal pages on the broker website.

    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:

    • Deposit/withdrawal operations are only available if appropriate functions are enabled for the trading account on the broker side.
    • The trading terminal does not perform any account deposit/withdrawal operations. The integrated functions redirect the user to the appropriate broker website pages.

  26. Android: Positions in history are sorted now by closing date.
  27. Android: Added marking of positions closed by Stop Loss or Take Profit with red and green vertical lines in the history section.
  28. Android: Added new fields in the trading symbol specification:

    • Category — the property is used for additional marking of financial instruments. For example, this can be the market sector to which the symbol belongs: Agriculture, Oil & Gas and others. The category is displayed only if the appropriate information is provided by the broker.
    • Exchange — the name of the exchange in which the security is traded. The category is displayed only if the appropriate information is provided by the broker.

  29. Android: Added Margin Call state indication in the trading section. Upon the emergence of this state, Margin, Free Margin and Margin Level parameters will be shown in red.
  30. Android: Fixed display of the OTP section opening button in tablets.
  31. Android: Other fixes and improvements.
  32. iPhone/iPad: Added ability to quickly switch to deposit/withdrawal pages on the broker website. For further details, please see the What's New list of MetaTrader 5 for Android.

  33. iPhone/iPad: Added dark mode support for iOS/iPadOS.
  34. iPhone/iPad: The one-time password section has become available in the iPad version.
  35. iPhone/iPad: The positions closed by Stop Loss or Take Profit are marked with red and green vertical lines in the history section.
  36. iPhone/iPad: Positions in history are sorted now by closing date. If the position has not yet been closed, its opening date is used for sorting.
  37. iPhone/iPad: Other fixes and improvements.
  38. Fixes based on crash logs.

The update will be available through the Live Update system.
If I have order arrows on chart and change account on broker then arrows still exist and can't delete this.

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:

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.

Since we are focused on performance as much as possible, here are the results of LLVM 9.0.0 vs MQL5 tests. Time in milliseconds, the less the better:
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
   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 ());
         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 ());
       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 ());
       return ( false );
//--- выводим записи
   Person person;

   for ( int i= 0 ; DatabaseReadBind(request,person); i++)
       Print (i, ":  " ,, " " ,, " " ,person.age, " " ,person.address, " " ,person.salary);

   Print ( "" );
//--- close all
   return ( true );

//| Script program start function                                    |
void OnStart ()

0 :   1 Paul 32 California 20000.0
1 :   3 Teddy 23 Norway 20000.0
2 :   4 Mark 25 Rich-Mond   65000.0 

Files:  2709 kb

Forum on trading, automated trading systems and testing trading strategies

New version of the MetaTrader 5 platform build 2265: DirectX functions for 3D visualization in MQL5 and setting up tools in the strategy tester

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

And a set of functions for working with SQLite databases .


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


I find the new frame design for build 2265 does not create much more space.

Is it possible to just add a  function of switching between hide and show all charts' top bar?

I wrote a script to remove all charts' top bar, however, it stopped working after this update.


 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.

Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Properties
Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Properties
All objects used in technical analysis are bound to the time and price coordinates: trendline, channels, Fibonacci tools, etc. But there is a number of auxiliary objects intended to improve the user interface that are bound to the always visible part of a chart (main chart windows or indicator subwindows): – defines the chart corner relative...

Now, mql5 has only rates copy functions for python integration.

I think we need 'indicator values copy functions'.

Please add this feature in future releases.


 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?

Juan Fernandez:

Can you put what registry keys are for change subwindows width?

HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics


I need to use colors for user determined functions, classes and member functions.

How can I do it?

If I can't do it in MetaEditor, please add this feature in future releases.