MetaTrader 5 build 1525: Representing trading history as positions and tester improvements

Now trading history can be additionally displayed in the form of positions. The terminal collects data on deals related to a position (position

27 January 2017

Terminal

  1. Now trading history can be additionally displayed in the form of positions. The terminal collects data on deals related to a position (position opening, additional volume, partial and full closure), and then combines the data into one record providing the following details:

    • Position opening and closing time determined by the first and last trade respectively
    • Position volume. If part of the position has been closed, the record contains the closed volume and the initial volume
    • The weighted average position opening price and its close price
    • The total financial result of deals related to the position




    On hedging accounts, the new history form is similar to the account history used in MetaTrader 4.




  2.   A new command has been added, which allows visualizing trades on a symbol's chart.

    • If you need to show deals of a selected position/symbol, click "Add [symbol name] Deals". Appropriate deals will be displayed on all currently open charts of the selected symbol. If there are no open charts of that symbol, a new chart will be opened.
    • Click "Add All Deals" in order to show deals of all symbols from the account history. Appropriate deals of corresponding symbols will be added to all open charts.




  3. Added display of the international name of a trading instrument in contract specification, as well as search by the international name in symbol management dialog.




  4. Added command for terminal window resolution setup. The function will be helpful for making videos. The menu provides the most popular resolution options used in various video services, such as YouTube.



  5. Chart templates and profiles have been moved from [Terminal Data Folder\Profiles] to [Terminal Data Folder\MQL5\Profiles]. Now you can easily add templates to the MQL5 Storage and access them from any PC.

MQL5

  1. Added support for resource variables. Development of some programs can be greatly facilitated by using such variables. For example, you can write a code of an OpenCL program in a separate CL file and then include it as a string into your MQL5 program resources. Before the update, such a code needed to be described as one large string variable.

    Declaration of the resource variable
    #resource path_to_resource_file as type_of_resource_variable name_of_resource_variable

    Features
    • Encoding of string files is determined automatically based on the BOM (the header). If BOM is absent, encoding is defined by the file contents. ANSI, UTF-8 and UTF-16 are supported. All strings are converted to Unicode.
    • Data of such a resource can only be addressed via a variable. Automatic addressing using "::<resource name>" is not available.
    • The special bitmap resource variable type shows to the compiler that the resource is an image. In this case, the resource variable gets the uint type.
    • When using a 24-bit image, the alpha channel component is set to 255 for all the image pixels.
    • When using a 32-bit image without the alpha channel, the alpha channel component is also set to 255 for all the image pixels.
    • When loading a 32-bit image with the alpha channel, the pixels are not processed in any way.
    • The bitmap type array resource variable may have two dimensions. In this case, the array size is defined as [image_height ][ image_width ].
    • If an array of one dimension is specified, the number of elements is equal to image_height*image_width.
    • If the resource file size is not a multiple of the array element size, the remaining data will be cropped. For example, if file size is 14 bytes, the number of elements for an int array will be equal to 3, while the other 2 bytes (14 - sizeof(int)*3) will be discarded.

    Examples of Use
    #resource "data.bin" as int ExtData[]             // declaring the numeric array containing data from the data.bin file
    #resource "data.bin" as MqlRates ExtData[]        // declaring the simple structures array containing data from the data.bin file
    
    #resource "data.txt" as string ExtCode            // declaring the string containing the data.txt file data
    #resource "data.txt" as string ExtCode[]          // declaring the string array containing the data.txt file data
    
    #resource "image.bmp" as bitmap ExtBitmap[]       // declaring the one-dimensional array containing a bitmap from the BMP file, array size = width * height
    #resource "image.bmp" as bitmap ExtBitmap2[][]    // declaring the two-dimensional array containing a bitmap from the BMP file, array size [hight][width]
    

  2. New property CHART_SHOW allows disabling chart display. Functions ChartGetInteger and ChartSetInteger are used to get and set the property.

    If false, drawing of any price chart attributes is disabled and all chart border indents are eliminated, including time and price scales, quick navigation bar, Calendar event labels, trade labels, indicator and bar tooltips, indicator subwindows, volume histograms, etc.

    Disabling the drawing is a perfect solution for creating a custom program interface using graphical resources.

    The graphical objects are always drawn regardless of the CHART_SHOW property value.

  3. New property CHART_KEYBOARD_CONTROL allows enabling/disabling chart control using the keyboard ("Home", "End", "PageUp", "+", "-", "Up arrow", etc.). Setting CHART_KEYBOARD_CONTROL to false disables chart scrolling and scaling while leaving intact the ability to receive the keys pressing events in OnChartEvent().

    Functions ChartGetInteger and ChartSetInteger allow getting and setting the property.

  4. Added new functions for working with OpenCL.

    New properties for working with memory
    Four new properties can be received through CLGetInfoIntegrer:
    • CL_DEVICE_MAX_WORK_GROUP_SIZE — the total number of local working groups available for an OpenCL device.
    • CL_KERNEL_WORK_GROUP_SIZE — the total number of local working groups available for an OpenCL program.
    • CL_KERNEL_LOCAL_MEM_SIZE — size of the local memory in bytes used by an OpenCL program for solving all parallel tasks in a group. Use CL_DEVICE_LOCAL_MEM_SIZE to receive the maximum available value.
    • CL_KERNEL_PRIVATE_MEM_SIZE — the minimum size of the private memory (in bytes) used by each task in the OpenCL program kernel.

    bool CLExecutionStatus(int kernel)
    Returns the OpenCL program execution status. The OpenCL program kernel handle is passed as the parameter.

    bool CLSetKernelArgMemLocal(int kernel_handle,int arg_index,ulong local_mem_size)
    Sets the local buffer as an argument of the kernel function. The OpenCL program kernel handle, the number of the OpenCL function argument and the buffer size are passed as parameters.

  5. New response code TRADE_RETCODE_LIMIT_POSITIONS has been added. The number of open positions simultaneously present on an account can be limited by the server settings. After a limit is reached, the server returns the TRADE_RETCODE_LIMIT_POSITIONS error when attempting to place an order. The limitation operates differently depending on the position accounting type:

    • Netting — number of open positions is considered. When a limit is reached, the platform disables placing new orders whose execution may increase the number of open positions. In fact, the platform allows placing orders only for the symbols that already have open positions. The current pending orders are not considered since their execution may lead to changes in the current positions but it cannot increase their number.
    • Hedging — pending orders are considered together with open positions, since a pending order activation always leads to opening a new position. When a limit is reached, the platform disables placing both new market orders for opening positions and pending orders.

  6. Fixed error that could occasionally cause skipping of ticks in the tick history.
  7. Fixed indirect template typing errors.
  8. Updated library of mathematical statistics functions.
  9. Added TranslateKey function that returns a Unicode character by a virtual key code considering the current input language and the status of control keys. The function uses ToUnicodeEx to convert keys pressed by a user into Unicode characters.
    void OnChartEvent(const int id,const long& lparam,const double& dparam,const string& sparam)
      {
       if(id==CHARTEVENT_KEYDOWN)
         {
          short sym=TranslateKey((int)lparam);
          //--- if the entered character is successfully converted to Unicode
          if(sym>0)
             Print(sym,"'",ShortToString(sym),"'");
          else
             Print("Error in TranslateKey for key=",lparam);
         }
      }

Market

  1. Fixed product page opening when downloading a demo version.

Tester

  1. After optimization completion, results are now automatically sorted by the "Results" column.
  2. A new command in the context menu of the optimization results tab allows to automatically open results when the optimization completes.
  3. The Strategy Tester now stays in the optimization mode after starting a single testing run. In earlier versions, if a single test was started from the optimization results tab, the strategy tester switched to the single testing mode. The optimization mode needed to be enabled in the settings in order to perform further optimization.
  4. Now sets of input parameters can be saved as local strategy tester settings, which can be conveniently accessed from the context menu, in addition to traditional .set files.




  5. Added UI translations into Mongolian, Hungarian, Romanian and Urdu.

MetaEditor

  1. Added ability to change the order of watched expressions in the debugger window. An expression can be dragged to the required position using the mouse.




  2. Fixed determining of source file encoding.
  3. Fixed search by files in the UTF-8 encoding.
  4. Fixed text selection with a mouse in case the text contains tabs.
  5. Added UI translations into Hungarian and Romanian.

Updated documentation.