- Added native support for .NET libraries with "smart"
functions import. Now .NET libraries can be used without writing special
wrappers — MetaEditor does it on its own.
To work with .NET library functions, simply import DLL itself
without defining specific functions. MetaEditor automatically imports
all functions it is possible to work with:
- Simple structures (POD, plain old data) — structures that contain only simple data types.
- Public static functions having parameters, in which only simple types and POD structures or their arrays are used
To call functions from the library, simply import it:
#import "TestLib.dll"
void OnStart()
{
int x=41;
TestClass::Inc(x);
Print(x);
}
The C# code of the Inc function of the TestClass looks as follows:
public class TestClass
{
public static void Inc(ref int x)
{
x++;
}
}
As a result of execution, the script returns the value of 42.
The work on support for .NET libraries continues. Their features are to be expanded in the future.
- Added support for working with WinAPI functions to Standard
Library. Now, there is no need to import libraries manually and describe
function signatures to use operating system functions in an MQL5
program. Simply include the header file from the MQL5\Include\WinAPI
directory.
WinAPI functions are grouped in separate files by their purpose:
- libloaderapi.mqh — working with resources
- memoryapi.mqh — working with memory
- processenv.mqh — working with environment
- processthreadsapi.mqh — working with processes
- securitybaseapi.mqh — working with OS security system
- sysinfoapi.mqh — obtaining system information
- winbase.mqh — common functions
- windef.mqh — constants, structures and enumerations
- wingdi.mqh — working with graphical objects
- winnt.mqh — working with exceptions
- winreg.mqh — working with the registry
- winuser.mqh — working with windows and interface
- errhandlingapi.mqh — handling errors
- fileapi.mqh — working with files
- handleapi.mqh — working with handles
- winapi.mqh — including all functions (WinAPI header files)
The binding works only with the 64-bit architecture.
- Added support for the inline, __inline and __forceinline
specifiers when parsing code. The presence of the specifiers in the code
causes no errors and does not affect the compilation. At the moment,
this feature simplifies transferring С++ code to MQL5.
Find more information about specifiers in MSDN.
- Significantly optimized execution of MQL5 programs. In some
cases, the performance improvement can reach 10%. Recompile your
programs in the new MetaEditor version to make them run faster.
Unfortunately, new programs will not be
compatible with previous terminal versions due to this additional
optimization. Programs compiled in MetaEditor version 1912 and later cannot be launched in terminal versions below 1912.
Programs compiled in earlier MetaEditor versions can run in new
terminals.
- Significantly optimized multiple MQL5 functions.
- Added new properties for attaching/detaching charts from the terminal main window and managing their position.
Added the following properties to the ENUM_CHART_PROPERTY_INTEGER enumeration:
- CHART_IS_DOCKED — the chart window is docked. If set to 'false', the chart can be dragged outside the terminal area.
- CHART_FLOAT_LEFT — the left coordinate of the undocked chart window relative to the virtual screen.
- CHART_FLOAT_TOP — the upper coordinate of the undocked chart window relative to the virtual screen.
- CHART_FLOAT_RIGHT — the right coordinate of the undocked chart window relative to the virtual screen.
- CHART_FLOAT_BOTTOM — the bottom coordinate of the undocked chart window relative to the virtual screen.
Added the following functions to the ENUM_TERMINAL_INFO_INTEGER enumeration:
- TERMINAL_SCREEN_LEFT — the left coordinate of the virtual
screen. A virtual screen is a rectangle that covers all monitors. If the
system has two monitors ordered from right to left, then the left
coordinate of the virtual screen can be on the border of two monitors.
- TERMINAL_SCREEN_TOP — the top coordinate of the virtual screen.
- TERMINAL_SCREEN_WIDTH — terminal width.
- TERMINAL_SCREEN_HEIGHT — terminal height.
- TERMINAL_LEFT — the left coordinate of the terminal relative to the virtual screen.
- TERMINAL_TOP — the top coordinate of the terminal relative to the virtual screen.
- TERMINAL_RIGHT — the right coordinate of the terminal relative to the virtual screen.
- TERMINAL_BOTTOM — the bottom coordinate of the terminal relative to the virtual screen.
- Added the volume_real field to the MqlTick and MqlBookInfo
structures. It is designed to work with extended accuracy volumes. The
volume_real value has a higher priority than 'volume'. The server will
use this value, if specified.
struct MqlTick
{
datetime time; // Last price update time
double bid; // Current Bid price
double ask; // Current Ask price
double last; // Current price of the Last trade
ulong volume; // Volume for the current Last price
long time_msc; // Last price update time in milliseconds
uint flags; // Tick flags
double volume_real; // Volume for the current Last price with greater accuracy
};
struct MqlBookInfo
{
ENUM_BOOK_TYPE type;
double price;
long volume;
double volume_real;
};
- Added new properties to the ENUM_SYMBOL_INFO_DOUBLE enumeration:
- SYMBOL_VOLUME_REAL — the volume of the last executed deal;
- SYMBOL_VOLUMEHIGH_REAL — the highest deal volume for the current day;
- SYMBOL_VOLUMELOW_REAL — the lowest deal volume for the current day.
Use the SymbolInfoDouble function to get these properties.
- Added the MQL_FORWARD property to the ENUM_MQL_INFO_INTEGER enumeration — forward test mode flag.
- Added the pack( integer_value ) property for structures. It
allows you to set the alignment of the fields arrangement within a
structure, which can be necessary when working with DLL. The values of
1, 2 ,4 ,8 and 16 are possible for integer_value.
If the property is not defined, the default alignment of 1 byte is used — pack(1).
Example of use:
struct A
{
char a;
int b;
};
struct B pack(4)
{
char a;
int b;
};
void OnStart()
{
Print("sizeof(A)=",sizeof(A));
Print("sizeof(B)=",sizeof(B));
}
Conclusion:
sizeof(A)=5
sizeof(B)=8
Find more information about alignment within structures in MSDN.
- Relaxed requirements for casting enumerations. In case of an
implicit casting, the compiler automatically substitutes the value of a
correct enumeration and displays a warning.
For the following code:
enum Main
{
PRICE_CLOSE_,
PRICE_OPEN_
};
input Main Inp=PRICE_CLOSE;
void OnStart()
{
}
The compiler displays the warning:
implicit conversion from 'enum ENUM_APPLIED_PRICE' to 'enum Main'
'Main::PRICE_OPEN_' instead of 'ENUM_APPLIED_PRICE::PRICE_CLOSE' will be used
Previously, the following error was generated in that case:
'PRICE_CLOSE' - cannot convert enum
The compiler will still display the error if enumerations are used incorrectly in the function parameters.
- Fixed compilation of template functions. Now, when using
overloaded template functions, only the necessary overload, rather than
all existing ones, is instantiated.
class X { };
void f(int) { }
template<typename T>
void a(T*) { new T(2); }
template<typename T>
void a() { f(0); }
void OnInit() { a<X>(); }
- Optimized some cases of accessing tick history via the CopyTicks* functions.
- Added the new TesterStop function allowing for early
completion of a test/optimization pass. When calling it, the entire
trading statistics and OnTester result are passed to the client terminal just like during the normal test/optimization completion.
- Added the new property for custom indicators #property
tester_everytick_calculate. It is used in the strategy tester and allows
for forced indicator calculation at each tick.
Updated documentation.