Novedades Metatrader 4

A partir de la compilación 574 de Metatrader 4 lanzada el 10 de enero, se producen importantes cambios en esta plataforma que pueden afectar de forma importante al funcionamiento de los indicadores y EAs que hayamos creado con versiones anteriores. Estos cambios también afectan a compilaciones posteriores (577, 578, 579, 582 y 600)

El principal cambio a tener en cuenta es que cambia la estructura de carpetas del programa. Como posiblemente ya sepan, anteriormente todos los indicadores, EAs y scripts se encontraban dentro de la carpeta Experts que cuelga de la instalación de Metatrader. Pues bien, esta estructura desaparece y ahora todo lo relacionado con la programación pasa a estar debajo de una nueva carpeta llamada MQL4 debajo de nuestra instalación de Metatrader. En concreto ahora tenemos el siguiente árbol de carpetas:

Carpeta de MetatraderMQL4

(Importante: en algunas instalaciones de Metatrader la carpeta se localiza en C:Users<Nombre de Usuario>AppDataRoamingMetaQuotesTerminal<secuencia de números y letras>MQL4)

Debajo de ella encontramos la siguiente estructura:

   Experts – Expert Advisors.
   Indicators – Indicadores.
   Scripts – Scripts.
   Include – Código de archivos *.mqh y *.mq4 utilizados por otros scripts.
   Libraries – Librerías en formato DLL y MQ4/EX4
   Images – Carpeta para guardar imágenes
   Files – Carpeta que funciona a modo de «sandbox». En esta carpeta Metatrader concede permisos al
             código para ejecutar operaciones con archivos.

En principio no debería suponer un problema migrar de una versión anterior a la nueva, ya que teóricamente Metatrader realiza las operaciones apropiadas y mueve los archivos al sitio adecuado al realizar la actualización. No obstante, se empieza a escuchar en los foros algunos comentarios negativos señalando que las cosas han dejado de funcionar. Es más si tenemos carpetas personalizadas Metatrader no las moverás en la actualización y habrá que moverlas manualmente (incluso cambiar la ruta en el código de nuestros scripts si hacíamos referencia a ellas).

No obstante si tenemos dudas de dónde estás las cosas con la nueva versión, Metaquotes ha tenido el detalle de incluir un enlace directo desde el menú File como podéis ver en la imagen adjunta:


Aparte de este cambio, tenemos otro que posiblemente sea más importante aún y que seguramente volverá loco a más de un programador: se ha revisado completamente el lenguaje MQL4 para asimilarlo completamente a MQL5, añadiendo clases y estructuras y ampliándose la sintaxis del lenguaje al nivel de C++ por lo que, según Metaquotes, ahora es posible crear EAs e indicadores de forma más sencilla y rápida. En mi opinión es un buen avance para el que empiece de cero con la plataforma pero los que ya trabajamos desde hace tiempo con el Metaeditor antiguo posiblemente nos las veamos para retocar el código y hacer que funcionen cosas que ya están programadas con la versión anterior de MQL4. Me temo que la intención es ir acostumbrando a los usuarios y a los brokers a que dentro de poco la versión 4 se quedará sin soporte y habrá que pasar por el aro de la versión 5.

Al margen de estos cambios importantes, tenemos algunas mejoras interesantes:

– Se ha añadido la pestaña Market dentro del Terminal que nos permitirá comprar y descargar cientos de EAs tanto de pago como gratuitos.

– Se ha cambiado la estructura del formato con el que se almacenaban datos históricos mediante RateInfo que pasa de:

struct RateInfo
  {
   unsigned int      ctm;  // bar open date
   double            open; // Open price
   double            low;  // Low price
   double            high; // High price
   double            close;// Close price
   double            vol;  // volume
  };

Al siguiente formato:

struct RateInfo
  {
   INT64             ctm;               // open date and time
   double            open;              // Open price (absolute value)
   double            high;              // Low price
   double            low;               // High price
   double            close;             // Close price
   UINT64            vol;               // tick volume
   INT32             spread;            // spread
   UINT64            real;              // trade volume
  };

– Se ha añadido un potente buscador en la parte superior derecha que nos permite localizar cualquier información dentro de nuestro Terminal así como dentro del extenso catálogo de código de las comunidades MQL4 y MQL5.

– Se ha añadido la posibilidad de recibir notificaciones push de las operaciones realizadas en la cuenta: órdenes canceladas, movidas, modificadas, margin call, órdenes pendientes, etc. La opción se activa desde el menú Tools->Options, pestaña Notifications.

 

– Ahora las alertas se muestran en el gráfico y se pueden mover directamente con el ratón, como podéis ver en la imagen adjunta:

 

 

– También es posible abrir demos y operar cuentas reales de otros brokers desde una sola Metatrader (antes también se podía hacer pero era un poco más rebuscado):

 

– Se han añadido los segundos en el timestamp de todas las órdenes, incluyendo las pendientes. También se ha aplicado este cambio a la hora mostrada en el panel de cotizaciones.

– Ahora las cuentas se muestran agrupadas por servidor, lo que permite identificar rápidamente a qué broker y servidor se conecta cada cuenta dentro del Navigator.

Y así hasta 57 cambios en total. Sin duda necesitaremos tiempo para digerirlos todos. Eso sí, al margen de las intenciones comerciales que pueda tener Metaquotes con todos estos cambios, está claro que Metatrader sigue siendo uno de los mejores programas de trading ;).

Saludos,
X-Trader

PD: Como anexo os pego aquí los principales cambios realizados por Metaquotes al lenguaje MQL4 para que tengáis una referencia (en inglés):

Changes in MQL4 Language

  • Added new char, short, long, uchar, ushort, uint, ulong and double data types. This will allow transferring codes from other C++ like languages. Data of various type is processed at different rates. Integer data is the fastest one to be processed. A special co-processor is used to handle the double-precision data. However, due to the complexity of the internal representation of floating-point data, it is processed slower than integer one. Typecasting has also been implemented.
  • Strings are now presented in Unicode format, though they were in ANSI format (single byte ones) before. That should be considered if the program uses DLLs and passes string variables to them. When calling Windows API functions, Unicode versions of these functions should be used.
  • Predefined Volume variable is now of long type. The time series for accessing the volumes also consist of long type arrays. It is recommended to use explicit casting of data having this type to the target type in old MQL4 programs to avoid type overflow error.
  • Structures and classes, object pointers, void type and this key word allowing an object to receive a reference to itself have been added. All object-oriented programming standards are supported:
  • ??P allows developing programs using classes. This facilitates debugging and development of large applications, as well as provides ability to reuse previously generated code multiple times due to inheritance. However, that does not mean that you cannot generate your MQL4 code in procedure-oriented style as before. You can develop your programs as you did in the past if you don’t need the new features.
  • init(), deinit() and start() predefined functions have remained for compatibility, however, OnInit(), OnDeinit(), OnStart(), OnCalculate() and OnTick() ones can now be used instead. Besides, new OnTimer(), OnChartEvent() and OnTester() predefined handler functions have been added. In the previous MQL4 versions, predefined functions could have any parameters and any return type. These functions were called by their names, not signatures. In the new MQL4, all predefined functions should exactly match their signatures. In other words, they should have a clearly defined set of parameters and a return type.
  • Now, variable names cannot contain special characters and points, and new MQL4 language keywords cannot be used as names. Old MQL4 programs can be recompiled with the new compiler in order to easily correct all such errors while following the compiler’s messages.
  • The Precedence rule now matches C language standards. If you are unsure, you can insert parentheses in old MQL4 apps to clearly indicate the priority to increase reliability.
  • Shortened conditions check is now used in logical operations, unlike the old MQL4 version where all expressions have been calculated and the check has been performed afterwards. Suppose there is a check of two conditions with the use of logical AND
      if(condition1 && condition2)
        {
         // some block of operations
        }

    If condition1 expression is false, calculation of condition2 expression is not performed, as false && true result is still equal to false.

  • Changed ArrayCopyRates() behavior – in the old MQL4 version, this function copied price series to double[][6] array. Now, the array from MqlRates structure elements should be used in order to receive time series:

    //Structure for storing data on prices, volumes and spread.
    struct MqlRates
      {
       datetime time;         // period start time
       double   open;         // Open price
       double   high;         // High price for the period
       double   low;          // Low price for the period
       double   close;        // Close price
       long     tick_volume;  // tick volume
       int      spread;       // spread
       long     real_volume;  // exchange volume
      };

    The new format of the function also performs virtual copying. In other words, the actual copying is not performed. When the copied values are appealed to, the price data is accessed directly.

    int  ArrayCopyRates(
       MqlRates&  rates_array[],   // MqlRates array passed by reference
       string     symbol=NULL,     // symbol
       int        timeframe=0      // timeframe
       );

    In order to maintain compatibility with old MQL4 applications, the old call format is also preserved. However, a real copying of data to double type array is now performed.

    int  ArrayCopyRates(
       void&     dest_array[][],    // array passed by reference
       string    symbol=NULL,       // symbol
       int       timeframe=0        // timeframe
       );

    This means that the necessary data should be copied to dest_array[][] again when changing values in time series (adding new bars, restructuring or updating the last bar’s Close price). In this case, the receiver array will be automatically distributed according to the necessary amount of the copied bars even if it has been declared statically.

  • In file operations, the number of simultaneously opened files can now reach 64 ones, while there could be no more than 32 ones in the old MQL4. Until recently, the files were always opened in FILE_SHARE_READ or FILE_SHARE_WRITE mode. Now, the necessary opening mode should be specified explicitly.
  • Working with functions, scope of variables and memory release in local arrays has also been changed. Since the number of changes is large enough, the new #property strict property has been introduced to provide maximum compatibility with the previous approach to developing MQL4 programs. When creating new MQL4 application using MQL wizard, this property is always added to the template. The table below contains the differences between MQL4, new MQL4 without using strict and new MQL4 with specified strict compilation mode
    #property strict

 

COMPARTIR EN: