MetaTrader 5 build 3520: 2FA/TOTP authentication using Google Authenticator

What's new in MetaTrader 5

25 November 2022


  1. Added 2FA/TOTP authentication using Google Authenticator and similar apps.

    The 2FA/TOTP authentication protects a trading account from unauthorized access even if its login and password are leaked. Authentication using Time-based One-time Password Algorithm (TOTP) can be implemented using various mobile apps. The most popular of them are Google Authenticator, Microsoft Authenticator, LastPass Authenticator and Authy. Now you can connect to your account in the MetaTrader 5 client terminal using one-time passwords generated by such Authenticator apps.

    To enable the two-factor authentication option, connect to your account and execute the "Enable 2FA/TOTP" command in the account context menu. Run the Authenticator app on your mobile device, click "+" to add your trading account and scan the QR code from the terminal. Enter the generated code in the "One-time password" field and click "Enable 2FA". A secret will be registered for your account on the broker's trading server.

    Added support for 2FA/TOTP authentication using Google Authenticator and similar apps.

    The saved secret will be used in the Authenticator app to generate an OTP code every time you connect to your account. Each password is valid for 30 seconds. After that a new one is generated.

    An additional OTP from the Authenticator app will be required for connecting to the account

    If you decide to remove the stored secret from the Authenticator app, you should first disable 2FA/TOTP authentication using the appropriate account context menu command. If the new 2FA/TOTP authentication method is not available on your account, please contact your broker.


  1. Fixed operation of the CopyTicks function for custom trading instruments. When working with custom symbols, previous session's initial ticks could be returned instead of requested data, under certain conditions.

  2. Added new enumeration values to get the last OpenCL error code and text description.
    1. Value CL_LAST_ERROR (code 4094) has been added to the ENUM_OPENCL_PROPERTY_INTEGER enumeration

      When obtaining the last OpenCL error via CLGetInfoInteger, the handle parameter is ignored. Error descriptions:
      For an unknown error code, the string "unknown OpenCL error N" is returned, where N is the error code.

      //--- the first handle parameter is ignored when obtaining the last error code
      int code = (int)CLGetInfoInteger(0,CL_LAST_ERROR);

    2. Value CL_ERROR_DESCRIPTION (4093) has been added to the ENUM_OPENCL_PROPERTY_STRING enumeration.
      A text error description can be obtained using CLGetInfoString. Error descriptions:

      When using CL_ERROR_DESCRIPTION, an error code should be passed as the handle parameter in CLGetInfoString. If CL_LAST_ERROR is passed instead of the error code, the function will return the last error description.

      //--- get the code of the last OpenCL error
      int    code = (int)CLGetInfoInteger(0,CL_LAST_ERROR);
      string desc; // to get the text description of the error
      //--- use the error code to get the text description of the error
         desc = "cannot get OpenCL error description, " + (string)GetLastError();
      //--- to get the description of the last OpenCL error without receiving the code, pass CL_LAST_ERROR  
      if(!CLGetInfoString(CL_LAST_ERROR,CL_ERROR_DESCRIPTION, desc))
         desc = "cannot get OpenCL error description, " + (string)GetLastError();
      The internal enumeration name is passed as the error description. Its explanation can be found at For example, the CL_INVALID_KERNEL_ARGS value means "Returned when enqueuing a kernel when some kernel arguments have not been set or are invalid."

  3. Fixed operation of the matrix::MatMul method. When working with large matrices, the terminal could crash on certain sizes.

Fixed errors reported in crash logs.