MetaTrader 5 Platform build 5326: Improvements and fixes - page 5

 

Still waiting for recognition on this bug:

//+------------------------------------------------------------------+
//|                                                  Playground1.mq5 |
//|                 No copyrights applied, common public shared code |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+



void OnStart()
{
    ResetLastError();
    const bool result = TextSetFont("My_surely_not_installed_font_", 12, FW_DONTCARE, 0);

    printf("Result of setting font: %i; _LastError: %i", result, _LastError);
}


Result of this code:

Result of setting font: 1; _LastError: 0


That cant be right.

 
Dominik Egert #:

I have noticed, most of the time CopyTicks is not initiating download of tick-data, though its hard to reproduce this with code other than:


Build ?
 
Dominik Egert #:

Still waiting for recognition on this bug:

Result of this code:

Result of setting font: 1; _LastError: 0

That cant be right.

Indirectly related to your post:

Ошибки, баги, вопросы

Vladislav Boyko, 2025.05.11 04:39

Where do these values come from? What font are they for? They don't match Arial.


#define _fontsize 18

void OnStart()
  {
   test("Arial", _fontsize);
   test("Arial Black", _fontsize);
   test("Arial Bold", _fontsize);
   test("askf12121212", _fontsize);
   test("hjhd34343434", _fontsize);
  }

void test(string font, int fontSize)
  {
   string text = "TextText";
   uint width, height;
   ResetLastError();
   if(!TextSetFont(font, fontSize * -10) || _LastError != ERR_SUCCESS)
      Print("TextSetFont error ", _LastError);
   ResetLastError();
   if(!TextGetSize(text, width, height) || _LastError != ERR_SUCCESS)
      Print("TextGetSize error ", _LastError);
   PrintFormat("font %15s | fontsize %i | text \"%s\" | width %3i | height %i", font, fontSize, text, width, height);
  }

Ошибки, баги, вопросы

Aleksandr Slavskii, 2025.05.11 04:56

It matches Arial for me.


MetaTrader 5 x64 build 4885 started for MetaQuotes Ltd.
Windows 10 build 19045, 24 x Intel Xeon  E5-2678 v3 @ 2.50GHz, AVX2, 116 / 127 Gb memory, 33 / 237 Gb disk, UAC, GMT+7
 
Alain Verleyen #:
Build ?
This. 5326
 
Dominik Egert #:

I have noticed, most of the time CopyTicks is not initiating download of tick-data, though its hard to reproduce this with code other than:


Could not it be an issue with your broker ? What is printed in the log ?

Because I tried and could not see a problem, either I got immediate results or there is a delay while the data are downloaded, all seems normal on my side.

 
Alain Verleyen #:

Could not it be an issue with your broker ? What is printed in the log ?

Because I tried and could not see a problem, either I got immediate results or there is a delay while the data are downloaded, all seems normal on my side.

Well, I did download the data manually, using the Symbols dialog. After doing that, CopyTicks went through without problems. But before, it didn't. Symbols I had trouble with: COCOA, DTE and SG30 from eightcap on demo.
 

Currently I am running into issues with the increased strictness of parameter checking on sigatures with the new compiler convention.

As an example, and I am sure, this will ripple through a lot of function signatures, as they are now incompatible with each other:

string  CharArrayToString(
   uchar  array[],              // array
   int    start=0,              // starting position in the array
   int    count=-1              // number of symbols
   uint    codepage=CP_ACP      // code page
   );

https://www.mql5.com/en/docs/convert/chararraytostring


is now incompatible with:

int  WebRequest(
   const string      method,           // HTTP method 
   const string      url,              // URL
   const string      cookie,           // cookie
   const string      referer,          // referer
   int               timeout,          // timeout
   const char        &data[],          // the array of the HTTP message body
   int               data_size,        // data[] array size in bytes
   char              &result[],        // an array containing server response data
   string            &result_headers   // headers of server response
   );

https://www.mql5.com/en/docs/network/webrequest

So it is not possible to print out data within the same function, as one refuses the others type as input.

I find this to be a very inconvenient regression, though I do welcome the more strict type checking, as it denies type-errors.


I guess a whole redesign of MQL-API functino signatures is now required to make it a bit more convenient, and to not break user-space, or legacy code.

Does anyone have a non-to-invasive suggestion on how this could be solved?


One approach could be to add in additional signatures, but all of them require copying the values from one typed array to another, and casting the values. - Though ArrayCopy would do that, it is very inconvenient to have to copy the values each time you want to pass them into another MQL-API function. - I consider this an invasive solution. - Any other options available?


EDIT:

As far as I can tell, its only affecting WebRequest, as it is the only function that consumes char&[] arrays. - All other, as far as I am aware are using uchar&[] parameters.

Documentation on MQL5: Conversion Functions / CharArrayToString
Documentation on MQL5: Conversion Functions / CharArrayToString
  • www.mql5.com
It copies and converts part of array of uchar type into a returned string. Parameters array[] [in]  Array of uchar type. start=0 [in]  ...
 
Dominik Egert #:

https://www.mql5.com/en/docs/network/webrequest

So it is not possible to print out data within the same function, as one refuses the others type as input.

Please try this first. There's a mistake in the documentation.
 
fxsaber #:
Please try this first. There's a mistake in the documentation.

Thank you for this hint, didnt notice this, actually. - So there are mixed signatures available:


void OnStart()
{
    const string    method      = NULL;
    const string    url         = NULL;
    const string    cookie      = NULL;
    const string    referer     = NULL;
    const int       timeout     = NULL;
    const int       data_size   = NULL;

    string  result_header = NULL;
    uchar   data[];
    char    result[];
    
    string data_out     = CharArrayToString(data);
    string result_out   = CharArrayToString(result);
    const int retval    = WebRequest(method,  url, cookie, referer, timeout, data, data_size, result, result_header);
}


Compiles fine.

 

I checked other function signatures, and there are incompatibilities given:

//+------------------------------------------------------------------+
//|                                                  Playground1.mq5 |
//|                 No copyrights applied, common public shared code |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+

void OnStart()
{
    const string    method      = NULL;
    const string    url         = NULL;
    const string    cookie      = NULL;
    const string    referer     = NULL;
    const int       timeout     = NULL;
    const int       data_size   = NULL;

    uint        u_data_size     = NULL;
    int         retval          = NULL;
    long        l_retval        = NULL;
    string      result_header   = NULL;
    MqlRates    rates           = {};
    uchar       uc_data[];
    char        c_data[];
    uchar       u_key[];
    char        key[];
    
    string data_out     = CharArrayToString(uc_data);
    string result_out   = CharArrayToString(c_data);
    retval = WebRequest(method,  url, cookie, referer, timeout, uc_data, data_size, c_data, result_header);

    retval = CryptDecode(CRYPT_BASE64, uc_data, u_key, c_data);
    retval = CryptDecode(CRYPT_BASE64, uc_data, key, c_data);

    retval = CharArrayToStruct(rates, uc_data);
    retval = CharArrayToStruct(rates, c_data);

    retval = StructToCharArray(rates, uc_data, u_data_size);
    retval = StructToCharArray(rates, c_data, data_size);                   // Not checking third parameter correctly??


    retval = CLGetDeviceInfo(INVALID_HANDLE, NULL, uc_data, u_data_size);
    retval = CLGetDeviceInfo(INVALID_HANDLE, NULL, c_data, u_data_size);    // Fails on char_array

    l_retval = OnnxCreateFromBuffer(uc_data, NULL);
    l_retval = OnnxCreateFromBuffer(c_data, NULL);                          // Fails on char_array

    retval = SocketRead(NULL, uc_data, u_data_size, timeout);               // Not checking fourth parameter correctly??
    retval = SocketRead(NULL, c_data, u_data_size, timeout);                // Fails on char_array

    retval = SocketSend(NULL, uc_data, u_data_size);                        // Not checking third parameter correctly??
    retval = SocketSend(NULL, c_data, data_size);                           // Fails on char_array

    retval = SocketTlsRead(NULL, uc_data, u_data_size);                     // Missing fourth parameter (timeout) ??
    retval = SocketTlsRead(NULL, c_data, u_data_size);                      // Fails on char_array

    retval = SocketTlsSend(NULL, uc_data, data_size);                       // Not checking third parameter correctly??
    retval = SocketTlsSend(NULL, c_data, u_data_size);                      // Fails on char_array

    
}

Compiler log:



So, there needs to be some adjustment done on MQs side of things.

BTW, is there a reason for SocketTlsRead to not have a timeout parameter?