New MetaTrader 5 platform build 2170: MQL5 scope, global Strategy Tester and built-in Virtual Hosting updates

 

The MetaTrader 5 platform update will be released on Friday, October 4, 2019 The new version features the following changes:

  1. Terminal: Completely redesigned built-in Virtual Hosting management options. All information about the rented terminal, as well as environment migration, stop and start functions, are now available in a separate tab of the Toolbox window.

    In earlier versions, Virtual Hosting functions were available in the context menu of the Navigator window. Now all the necessary information and control commands are conveniently arranged under the "VPS" tab:




    Basic subscription information appears on the left side:

    • Connection data: comparison of network delays between your terminal on the hosting server and a terminal running on a local PC.
    • Trading account for which hosting was rented and the payment plan.
    • Unique subscription identifier. A click on the ID opens the Hosting section in the MQL5.community user profile, from which the subscription can be managed.
    • Registration date and current state. If the hosting service is stopped, an appropriate status will instantly appear here.

    Using the Start/Stop button, the virtual terminal can be quickly started or stopped.

    Data about hosting server hardware and CPU consumption charts are displayed in the right hand side window section. Based on the displayed information, you will be able to respond in a timely manner if your Expert Advisor or indicator utilizes excessive memory or CPU time.

    Information about the last trading environment migration as well as migration commands are also available here. These commands enable fast environment migration after purchasing a subscription.

    A virtual platform can be rented from the "VPS" tab. The renting process has not changed and it is still fast and easy. You only need to select a plan and a suitable payment method. The best server for connecting to your broker will be selected automatically.




  2. Terminal: Added ability to quickly switch to deposit/withdrawal operations 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: in the accounts menu in Navigator and in Toolbox > Trade tab:



    • 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.
  3. Terminal: 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.

    Commissions
    Information on commissions charged by a broker for the symbol deals. Calculation details are displayed here:

    • Commission may be single-level and multilevel, i.e. be equal regardless of the deal volume/turnover or can depend on the size. Appropriate data is displayed in the terminal.
    • Commission can be charged immediately upon deal execution or at the end of a trading day/month.
    • Commission can be charged depending on deal direction: entry, exit or both operation types.
    • Commission can be charged per lot or deal.
    • Commission can be calculated in money, percentage or points.

    For example, the following entry means that a commission is charged immediately upon deal entry and exit. If the deal volume is between 0 to 10 lots, a commission of 1.2 USD is charged per operation. If the deal volume is between 11 to 20 lots, a commission of 1.1 USD is charged per each lot of the deal.
    Commission | Instant, volume, entry/exit deals
    0  - 10  | 1.2 USD per deal
    11 - 20  | 1.1 USD per lot



  4. Terminal: Additional options related fields have been added to symbol specification:

    • Option type — call or put
    • Underlying — the underlying symbol of the option
    • Strike price — option strike price

  5. Terminal: Added support for the delivery of options "Greeks": delta, gamma, vega, theta, rho. Brokers can provide additional information related to such instruments. The data is displayed under the Details section of the Market Watch window and it can be used for advanced trade analysis:




  6. Terminal: The Crosshair tool now shows the distance between price levels in percentage, in addition to previously available pips:




  7. Terminal: Added the display of a resulting price in trading dialogs during Market and Exchange execution operations, if this price is available at the time a response is received from the broker:




  8. Terminal: Fixed occasional error due to which the "Show All" command in the Market Watch window could fail to show the list of all available trading instruments.

  9. MQL5: The scope operation has been revised and thus MQL5 is even closer to C++. This provides MQL5 programmers with wider possibilities in operations with third-party libraries. The update eliminates the need to modify libraries and to unify identifiers.

    Example: Code contains declaration of two structures with the same name even though they belong to different classes. In earlier versions such a declaration produced a compilation error: "identifier already used". Now this code will be successfully compiled and executed. For a proper access to the desired variable/structure/function from outside of its scope, you should specify a class (in this case it is CBar::Item).
    class CFoo
      {
    public:
       struct Item { int x; };
      };
    //+------------------------------------------------------------------+
    class CBar
      {
    public:
       struct Item { int x; };
      };
      
    CBar::Item item;  // proper declaration of the Item structure from the Bar class
    Item       item;  // incorrect declaration
    Added namespace support which provides more possibilities when using third-party code/libraries in MQL5 applications.

    #define PrintFunctionName() Print(__FUNCTION__)
    
    namespace NS
    {
    void func()
      {
       PrintFunctionName();
      }
    
    struct C
      {
       int               x;
                         C() { PrintFunctionName(); };
      };
    }
    
    struct C
      {
       int               x;
                         C() { PrintFunctionName(); };
      };
    
    //+------------------------------------------------------------------+
    //|                                                                  |
    //+------------------------------------------------------------------+
    void func()
      {
       PrintFunctionName();
      }
    //+------------------------------------------------------------------+
    //| Script program start function                                    |
    //+------------------------------------------------------------------+
    void OnStart()
      {
       func();
       NS::func();
    
       C c;
       NS::C ac;
      }
    Upon execution the following result is displayed as output:
    2019.09.18 13:39:35.947    TestScript (AUDCAD,H1)    func
    2019.09.18 13:39:35.949    TestScript (AUDCAD,H1)    NS::func
    2019.09.18 13:39:35.949    TestScript (AUDCAD,H1)    C::C
    2019.09.18 13:39:35.949    TestScript (AUDCAD,H1)    NS::C::C

  10. MQL5: New version features faster access to timeseries data using the following function: iTime, iOpen, iHigh, iLow, iClose, iVolume, iTickVolume, iSpread.

  11. MQL5: Added support for the "=delete" attribute. It allows prohibition on the use of certain class methods.
    class A
      {
       void              operator=(const A &)=delete;    // prohibit object copying operator
      };
    
    class B : public A
      {
      };
    
    //+------------------------------------------------------------------+
    //| Script program start function                                    |
    //+------------------------------------------------------------------+
    void OnStart()
      {
       A a1,a2;
       B b1,b2; 
      
       a1=a2;
       b1=b2;
      }
    In this example, the compiler will return errors for "a1=a2" and "b1=b2":
    attempting to reference deleted function 'void A::operator=(const A&)'
       function 'void A::operator=(const A&)' was explicitly deleted here

    attempting to reference deleted function 'void B::operator=(const B&)'
       function 'void B::operator=(const B&)' was implicitly deleted because it invokes deleted function 'void A::operator=(const A&)'

  12. MQL5: The following values have been added to the ENUM_SYMBOL_INFO_STRING enumeration:

    • SYMBOL_CATEGORY — symbol category. It 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.
    • SYMBOL_EXCHANGE — the name of the exchange in which the symbol is traded.

  13. MQL5: Added support for position closure by FIFO rule.

    • ACCOUNT_FIFO_CLOSE value has been added to ENUM_ACCOUNT_INFO_INTEGER. It indicates that positions can be closed only by the FIFO rule. If the property value is true, then positions for each instrument can only be closed in the same order in which they were opened: the oldest one should be closed first, then the next one, etc. In case of an attempt to close positions in a different order, an error will be returned. The property value is always 'false' for accounts without hedging position management (ACCOUNT_MARGIN_MODE!=ACCOUNT_MARGIN_MODE_RETAIL_HEDGING).
    • New return code: MT_RET_REQUEST_CLOSE_ONLY — the request is rejected, because the rule "Only closing of existing positions by FIFO rule is allowed" is set for the symbol

    There are three main methods to close a position:

    • Closing from the client terminal: the trader closes the position manually, using a trading robot, based on the Signals service subscription, etc. In case of an attempt to close a position, which does not meet the FIFO rule, the trader will receive an appropriate error.
    • Closing upon Stop Loss or Take Profit activation: these orders are processed on the server side, so the position closure is not requested on the trader (terminal) side, but is initiated by the server. If Stop Loss or Take Profit triggers for a position, and this position does not comply with the FIFO rule (there is an older position for the same symbol), the position will not be closed.
    • Closing upon Stop Out triggering: such operations are also processed on the server side. In a normal mode, in which FIFO-based closing is disabled, in case of Stop Out positions are closed starting with the one having the largest loss. If this option is enabled, the open time will be additionally checked for losing positions. The server determines losing positions for each symbol, finds the oldest position for each symbol, and then closes the one which has the greatest loss among the found positions.

  14. Added options for parameter grouping via "input group". This enables visual separation of parameters based on their underlying logic.

    In the below Expert Advisor code,input parameters are grouped according to their purpose:
    input group           "Signal"
    input int             ExtBBPeriod    =20;         // Bollinger Bands period
    input double          ExtBBDeviation =2.0;        // deviation
    input ENUM_TIMEFRAMES ExtSignalTF    =PERIOD_M15; // BB timeframe
    
    input group           "Trend"
    input int             ExtMAPeriod    =13;         // Moving Average period
    input ENUM_TIMEFRAMES ExtTrendTF     =PERIOD_M15; // MA timeframe
    
    input group           "ExitRules"
    input bool            ExtUseSL       =true;       // use StopLoss
    input int             Ext_SL_Points  =50;         // StopLoss in points
    input bool            ExtUseTP       =false;      // use TakeProfit
    input int             Ext_TP_Points  =100;        // TakeProfit in points
    input bool            ExtUseTS       =true;       // use Trailing Stop
    input int             Ext_TS_Points  =30;         // Trailing Stop in points
    
    input group           "MoneyManagement"
    sinput double         ExtInitialLot  =0.1;        // initial lot value
    input bool            ExtUseAutoLot  =true;       // automatic lot calculation
    
    input group           "Auxiliary"
    sinput int            ExtMagicNumber =123456;     // EA Magic Number
    sinput bool           ExtDebugMessage=true;       // print debug messages
    When such an Expert Advisor is launched in the Strategy Tester, input parameter blocks can be collapsed or expanded by a double click on the group name, as well as all parameters within a group can be selected for optimization with a single check box.




  15. MQL5: Fixed import of DLL functions with names matching MQL5 function names. Example:
    #import "lib.dll"
    int func();
    #import
    //+------------------------------------------------------------------+
    //|                                                                  |
    //+------------------------------------------------------------------+
    int func()
      {
       return(0);
      }
    //+------------------------------------------------------------------+
    //| Script program start function                                    |
    //+------------------------------------------------------------------+
    void OnStart()
      {
       Print( func() );
      }
    In earlier versions, the following error returned during compilation:
    'func' - ambiguous call to overloaded function with the same parameters
    could be one of 2 function(s)
       int func()
       int func()
    Now, instead of the error, the built-in MQL5 function with a higher priority will be used by default. The imported function can be called by explicitly specifying the scope:
    void OnStart()
      {
       Print( lib::func() );
      }
  16. MQL5: Fixed specification of time in economic calendar news. Now events are delivered by taking into account the time zone of the trade server to which the terminal is connected, instead of the local computer time zone.
  17. MQL5: Fixed excessive memory consumption in the Copyticks and CopyTicksRange functions.
  18. Signals: Fixed display of signal charts when working in Wine (Mac OS and Linux).
  19. Tester: Big Strategy Tester update. New start page, redesigned settings page, improved usability.

    Start page
    Now, after tester launch, instead of multiple settings the user sees a list of standard tasks, by selecting which they can quickly start testing. The new design is primarily intended for unexperienced users.

    We have selected the most frequent strategy testing and optimization tasks and we have added them in the start page. In addition, one of the previously performed tasks can be restarted from the start page. If you have run a lot of tasks and they do not fit into the start page, use the search bar. You can find a test by any parameter: program name, symbol, timeframe, modeling mode, etc.




    Hiding irrelevant parameters
    After selecting a task, the user proceeds to further testing parameters: selection of an Expert Advisor, symbol, testing period, etc. All irrelevant parameters which are not required for the selected tasks are hidden from the setup page. For example, if mathematical calculations are selected, only two parameters should be specified: selection of a program to be tested and the optimization mode. Testing period, delay and tick generation settings will be hidden.




    Convenient testing setup
    For convenience some of the parameters on the setup page have been rearranged. Extended explanations have been added for the delay and visualization parameters. In addition, testing settings can now be saved and uploaded manually, and thus a trader can quickly return to previous settings.




    Using the same tab you can quickly open the program for editing in MetaEditor.

    Profit calculation in pips
    Using the settings, you can enable profit calculation in pips. This mode accelerates testing while there is no need to recalculate profit to deposit currency using conversion rates (and thus there is no need to download the appropriate price history). Swap and commission calculations are eliminated in this mode.




    Please note that when calculating profit in pips, the deal volume does not matter. Only the number of won/lost pips is calculated for each deal. Also margin control is not performed in this mode. Use it only for quick and rough strategy estimation and then check the obtained results using more accurate modes.

    General improvements
    Testing start/stop button and progress bar have been moved to the tabs bar. Thus, the user can control the process from any Strategy Tester section. Testing start/stop commands have also been added to context menus of settings and inputs sections.




  20. Tester: The optimization chart can now be displayed in the main working area of the terminal, instead of displaying in a separate strategy tester section. This way, much more space becomes available for data analysis. The 3D visualization system has also been updated.




  21. Tester: Added saving of optimization cache for the "All symbols in Market Watch" mode.
  22. Tester: Added saving of test cache.

    In earlier versions, executed task results were saved to files only when optimizing Expert Advisors. Now, cache files are also saved during single tests, using which users can return to previous calculations and view statistics, balance, equity and deposit loading graphs, at any time. In future releases, this option will enable comparison of testing results.

    To load previous test results, use the new Tester start page: click "Previous results" and select the desired site:




  23. Tester: Significantly accelerated testing and optimization, including operations performed using the MQL5 Cloud Network.
  24. Tester: Fixes and optimized operations with frames.
  25. MetaEditor: Added ability to configure code styler.

    The MetaEditor includes a built-in code styler, which enables automatic formatting of program text in accordance with the adopted standard. Now in addition to common style, you can use other popular standards. To do this, open MetaEditor settings and select the desired style:




    The following parameters can be additionally set for the styler:

    Spaces per indent
    Sets the number of spaces used in aligning of nested constructions:
    if(condition)
      {
       //---
      }

    Replace tabs with spaces
    If this option is enabled, the styler will replace all tabs in the code with spaces. The number of characters per tab is set in the General section.

    Delete empty lines
    When this option is enabled, the styler will delete all lines having only a line break character.

    Insert spaces after commas and semicolons
    When this option is enabled, the styler will visually separate constructions with element enumerations. Example:
    // before styling
    ParameterGetRange("InpX",enable,x_cur,x_start,x_step,x_stop);
    // after styling
    ParameterGetRange("InpX", enable, x_cur, x_start, x_step, x_stop);

    Insert spaces around declaration operators
    When this option is enabled, the styler will insert spaces around the assignment, equality, comparison, and other operators. Example:
    // before styling
    if(x==1&y!=2)
      {
       int a=0;
      }
    // after styling
    if(x == 1 & y != 2)
     {
      int a = 0;
     }

  26. MetaEditor: "Show in Navigator" command has been added to the file bookmarks context menu. Thus, the user can easily find a file opened for editing among the editor's folder structure.




  27. MetaEditor: Fixed display of the 'union' keyword in tooltips.
  28. The user interface has been additionally translated into 18 new languages:

    • European Region — Swedish, Lithuanian, Danish, Latvian, Estonian, Serbian, Slovenian, Slovak, Finnish, Georgian
    • Asian region — Javanese, Marathi, Bengali, Punjabi, Tamil, Telugu
    • African Region — Swahili, Hausa

    The platform interface is now available in 50 languages, which are spoken by more than 4 billion people.

    To set you language for the interface, navigate to the "View / Language" menu at the top of the terminal.

  29. Documentation has been updated.
  30. Fixes based on crash logs.

The update will be available through the Live Update system.

 

Hi, I've installed today build 2170.

In the visualbactester it's not possible anymore to use my template with the indicators I want.

Probably it's  a bug or is there another way to apply a template during visual mode ?


Thx,


Danny

 
Added options for parameter grouping via "input group". This enables visual separation of parameters based on their underlying logic.

This is great, thanks!

But...

Without the option of deciding which groups should appear open/closed by default and without the option to "expand/colapse all" the utility is very limited.

 
Henrique Vilela:

This is great, thanks!

But...

Without the option of deciding which groups should appear open/closed by default and without the option to "expand/colapse all" the utility is very limited.


I agree with Henrique Vilela!!

:)

 
Henrique Vilela:

This is great, thanks!

But...

Without the option of deciding which groups should appear open/closed by default and without the option to "expand/colapse all" the utility is very limited.

Buttons and options more ... Be careful not to make a gas plant!

 

I've noticed a misbehavior when testing the "input group", regarding static variables.

If the code contains static variables and input groups are used, the compiler throws an error when I try to set a new value to the static variable: "constant cannot be modified".

It seems that the static variable is treated as const. The following code, took from the docs, can lead to this error. If we take out the first line (input group) the code is compiled correctly.


input group "My inputs"

input int inputTest=0;


int Counter() 

  { 

   static int count = 0; 

   count++; 

   if(count%100==0) Print("Function Counter has been called ",count," times"); 

   return count; 

  }

   

void OnStart() 

  { 

//--- 

   int c=345; 

   for(int i=0;i<1000;i++) 

     { 

      c=Counter(); 

     } 

   Print("c =",c); 

   

  }



Best regards,

 

All these changes look really great, but I'd like to ask a question about linking to 64 bit C# .NET dll.

I have one that I am in the process of coding using Visual Studio.  It was working with no errors before this latest Metatrader 5 build, and now the MQL5 code cannot find any of the functions exposed by the dll.

In the original (working) code, I simply used

#import "MyDll.dll"

 The MQL5 code which implements the dll functions now won't compile any more, eg

MyDll::ExportedFunction();

I noted that in item 15 above the function is explicitly declared, similar to the approach for a 32 bit MQL4 import.  It didn't need to before this build, but I tried it anyway

#import "MyDll.dll"
void ExportedFunction();
#import

MyDll:ExportedFunction();

This does compile without error, but I then get a runtime error in Metatrader 5 Experts log saying 

Cannot find 'ExportedFunction' in MyDll.dll

Unresolved import function call


Any ideas?

 
Paul:

All these changes look really great, but I'd like to ask a question about linking to 64 bit C# .NET dll.

I have one that I am in the process of coding using Visual Studio.  It was working with no errors before this latest Metatrader 5 build, and now the MQL5 code cannot find any of the functions exposed by the dll.

In the original (working) code, I simply used

 The MQL5 code which implements the dll functions now won't compile any more, eg

I noted that in item 15 above the function is explicitly declared, similar to the approach for a 32 bit MQL4 import.  It didn't need to before this build, but I tried it anyway

This does compile without error, but I then get a runtime error in Metatrader 5 Experts log saying 

Cannot find 'ExportedFunction' in MyDll.dll

Unresolved import function call


Any ideas?

Fixed!  There is a change of behaviour, but this aligns to these release notes: https://www.metatrader5.com/en/releasenotes/terminal/1898.  My working code had followed another example, which will no longer compile, which used the Dll name as the qualifier for the exported functions.  The qualifier should be the C# class name.

MetaTrader 5 platform build 1930: Floating window charts and .Net libraries in MQL5
MetaTrader 5 platform build 1930: Floating window charts and .Net libraries in MQL5
  • 2018.10.26
  • MetaQuotes Software Corp.
  • www.metatrader5.com
Now you can detach financial symbol charts from the trading terminal window. This feature is convenient when using multiple monitors. Thus, you may set the main platform window on one monitor to control your account state, and move your charts to the second screen to observe the market situation. To detach a chart from the terminal, disable...
 
Antonio Guglielmi:

I've noticed a misbehavior when testing the "input group", regarding static variables.

If the code contains static variables and input groups are used, the compiler throws an error when I try to set a new value to the static variable: "constant cannot be modified".

It seems that the static variable is treated as const. The following code, took from the docs, can lead to this error. If we take out the first line (input group) the code is compiled correctly.


input group "My inputs"

input int inputTest=0;


int Counter() 

  { 

   static int count = 0; 

   count++; 

   if(count%100==0) Print("Function Counter has been called ",count," times"); 

   return count; 

  }

   

void OnStart() 

  { 

//--- 

   int c=345; 

   for(int i=0;i<1000;i++) 

     { 

      c=Counter(); 

     } 

   Print("c =",c); 

   

  }


Best regards,

Thank you for your message.

Fixed.

Please wait for updates.

 

Hi, after this build my code is not compiling anymore.

I am getting erros on the usage on enumeration, it is not recognizing an include of a custom enumeration.


Example:

//+------------------------------------------------------------------+

//|   ClassA                                                      |

//+------------------------------------------------------------------+

class ClassA

  {

private:

public: 

   enum ENUM_TEST {TESTA,TESTB}; // List of structure type



   void              ClassA(void){};

   void             ~ClassA(void){};           // Destructor

  };



//+------------------------------------------------------------------+

//|   ClassB                                                         |

//+------------------------------------------------------------------+

#include <ClassA.mqh>

class ClassB

  {

private:

   ENUM_TEST            test;               // Default category

public:

   void              ClassB(void) {};

   void             ~ClassB(void) {};          // Destructor

  };

Compilation ERROR:

'ENUM_TEST' - unexpected token, probably type is missing? ClassB.mqh 8 4


Reason: