mql5 documentation errors, defaults or inconsistencies. - page 3

 

CopyBuffer() (and CopyIndicatorBuffer) documentation :

Note

When requesting data from the indicator, if requested timeseries are not yet built or they need to be downloaded from the server, the function will immediately return -1, but the process of downloading/building will be initiated.

When requesting data from an Expert Advisor or script, downloading from the server will be initiated, if  the terminal does not have these data locally, or building of a required timeseries will start, if data can be built from the local history but they are not ready yet. The function will return the amount of data that will be ready by the moment of timeout expiration.

This note should be removed, as CopyBuffer() is not related to timeseries.

Additionally a note should be added about indicators buffers updates when an indicator is running using iCustom.

Documentation on MQL5: Timeseries and Indicators Access / CopyBuffer
Documentation on MQL5: Timeseries and Indicators Access / CopyBuffer
  • www.mql5.com
CopyBuffer - Timeseries and Indicators Access - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Comments that do not relate to this topic, have been moved to "Off-topic posts".
 

Forum on trading, automated trading systems and testing trading strategies

ENUM_COPY_TICKS values different from reference

Fernando Carreiro, 2023.06.13 19:36

That may be the case, but the documentation is still incorrect ... Documentation on MQL5: Matrix and Vector Methods / Initialization / CopyTicks

Below is a copy of the online version and the values are incorrect as demonstrated in my code above.

ENUM_COPY_TICKS

The ENUM_COPY_TICKS enumeration contains the flags to specify the type of data to be passed to the matrix or array. The flag combination allows getting several series from the history in one request. The order of the rows in the matrix will correspond to the order of the values in the ENUM_COPY_TICKS enumeration. In other words, the row with High data will always be higher in the matrix than the row with Low data.

ID

Value

Description

COPY_TICKS_TIME_MS

1

Tick time in milliseconds

COPY_TICKS_BID

2

Bid price

COPY_TICKS_ASK

4

Ask price

COPY_TICKS_LAST

8

Last price (last deal price)

COPY_TICKS_VOLUME

16

Last price Volume

COPY_TICKS_FLAGS

32

Tick Flags

Data arrangement

 

 

COPY_TICKS_VERTICAL

32768

Ticks are copied into the matrix along the vertical axis. The received ticks will be arranged vertically in the matrix, i.e., the oldest ticks will be in the first row, while the most recent ticks will be in the last matrix row.

 With default copying, ticks are added into a matrix along the horizontal axis.

 The flag is only applicable when copying to a matrix.

Forum on trading, automated trading systems and testing trading strategies

ENUM_COPY_TICKS values different from reference

Fernando Carreiro, 2023.06.13 18:44

As a supplement to your information, I get the following ...

#define PrintTickFlag( _flag ) PrintFormat( "%+24s = %8d = %8X", #_flag, _flag, _flag )

void OnStart() {
   PrintTickFlag( TICK_FLAG_BID    );
   PrintTickFlag( TICK_FLAG_ASK    );
   PrintTickFlag( TICK_FLAG_LAST   );
   PrintTickFlag( TICK_FLAG_VOLUME );
   PrintTickFlag( TICK_FLAG_BUY    );
   PrintTickFlag( TICK_FLAG_SELL   );

   PrintTickFlag( COPY_TICKS_INFO     );
   PrintTickFlag( COPY_TICKS_TRADE    );
   PrintTickFlag( COPY_TICKS_ALL      );
   PrintTickFlag( COPY_TICKS_VERTICAL );
   PrintTickFlag( COPY_TICKS_TIME_MS  );
   PrintTickFlag( COPY_TICKS_BID      );
   PrintTickFlag( COPY_TICKS_ASK      );
   PrintTickFlag( COPY_TICKS_LAST     );
   PrintTickFlag( COPY_TICKS_VOLUME   );
   PrintTickFlag( COPY_TICKS_FLAGS    );
};
      TICK_FLAG_BID =        2 =        2
      TICK_FLAG_ASK =        4 =        4
     TICK_FLAG_LAST =        8 =        8
   TICK_FLAG_VOLUME =       16 =       10
      TICK_FLAG_BUY =       32 =       20
     TICK_FLAG_SELL =       64 =       40

    COPY_TICKS_INFO =        1 =        1
   COPY_TICKS_TRADE =        2 =        2
     COPY_TICKS_ALL =        3 =        3
COPY_TICKS_VERTICAL =    32768 =     8000
 COPY_TICKS_TIME_MS =    65536 =    10000
     COPY_TICKS_BID =   131072 =    20000
     COPY_TICKS_ASK =   262144 =    40000
    COPY_TICKS_LAST =   524288 =    80000
  COPY_TICKS_VOLUME =  1048576 =   100000
   COPY_TICKS_FLAGS =  2097152 =   200000

Forum on trading, automated trading systems and testing trading strategies

ENUM_COPY_TICKS values different from reference

Tobias Johannes Zimmer, 2023.06.13 21:07

Oh yes, that is another thing i noticed. Each time I press F1 while cursor is on the normal CopyTicksRange function, I get the reference article for the vector/matrix function.

 

Missing error code translations. - Incomplete list of error codes.


French, Japanese:

Error codes: 4023 - 4025, 5700 - 5706, 5800 - 5808

https://www.mql5.com/fr/docs/constants/errorswarnings/errorcodes

https://www.mql5.com/ja/docs/constants/errorswarnings/errorcodes

Documentation sur MQL5: Constantes, Enumérations et Structures / Codes d'Erreurs et Avertissements / Erreurs d'Exécution
Documentation sur MQL5: Constantes, Enumérations et Structures / Codes d'Erreurs et Avertissements / Erreurs d'Exécution
  • www.mql5.com
Erreurs d'Exécution - Codes d'Erreurs et Avertissements - Constantes, Enumérations et Structures - Référence MQL5 - Référence sur le langage de trading algorithmique/automatisé pour MetaTrader 5
 

Wrong specification of function parameters:

SocketTlsCertificate()- Get data on the certificate used to secure network connection.


The parameters 2-6 are specified as [in] parameters, but actually they are [out] parameters, as can be seen by the example, and the fact, they are specified as reference parameter types.


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

Documentation on MQL5: Network Functions / SocketTlsCertificate
Documentation on MQL5: Network Functions / SocketTlsCertificate
  • www.mql5.com
SocketTlsCertificate - Network Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

Wondering where these functions went, or if they ever existed....

https://www.mql5.com/en/docs/basis/variables#array_built_in_methods


    int array[];
    int _sec_arr[];
    
    array.Fill(1);
    array.Free();
    array.Resize(5);
    array.Print();
    array.Size();
    array.IsDynamic();
    array.IsIndicatorBuffer();
    array.IsSeries();
    array.AsSeries();
    array.Copy(_sec_arr);
    array.Compare(_sec_arr);
    array.Insert(_sec_arr, 0, 0, _sec_arr.Size());
    array.Remove(1, 1);
    array.Reverse();
    array.Swap(_sec_arr);
    array.Sort();
    array.Search(1, NULL);
    array.Find(1, NULL);
    array.Select(1, NULL);

Compile result:


Documentation on MQL5: Language Basics / Variables
Documentation on MQL5: Language Basics / Variables
  • www.mql5.com
Variables - Language Basics - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

Missing type specifier beyond "unsigned" in documentation:

https://www.mql5.com/en/docs/basis/types/matrix_vector


vector matrix.Row(const unsigned nrow)

 

Return a row vector

vector matrix.Col(const unsigned ncol)

 

Return a column vector

unsigned matrix.Rows()

 

Return the number of rows in a matrix

unsigned matrix.Cols()

 

Return the number of columns in a matrix


My guess is this should be a long type. - "unsigned long" or "ulong" as both are valid in MQL5

EDIT:

I suggest also mentioning what a scalar type is, as these would refere to (probably) float, double and signed as well as unsigned versions of char, short, int, long. - But also color and datetime could be used, as they are just a different interpretation of uint(color) and long(datetime).

- Have I forgotton anything?

Documentation on MQL5: Language Basics / Data Types / Matrices and vectors
Documentation on MQL5: Language Basics / Data Types / Matrices and vectors
  • www.mql5.com
Matrices and vectors - Data Types - Language Basics - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

Documentation on vectors and matrices seems not complete at all, and has quite some errors:

https://www.mql5.com/en/docs/basis/types/matrix_vector


template <typename V_Type>
struct _vector
{
    public:
    // Local representation
    vector<V_Type>  _v;

    // Constructors
    _vector()
    {};

    _vector(const vector<V_Type> &p_in) :
        _v(p_in)
    {};

    // Function wrappers
    void            FromString(const string source, const string sep = " ")             { _v.FromString(source, sep); };
    void            Arange(const long start, const long stop, const long step = 1)      { _v.Arange(start, stop, step); };
    double          ArgMax()                                                            { return(_v.ArgMax()); };
    double          ArgMin()                                                            { return(_v.ArgMin()); };
    double          Max()                                                               { return(_v.Max()); };
    double          Mean()                                                              { return(_v.Mean()); };
    double          Min()                                                               { return(_v.Min()); };
    double          Sum()                                                               { return(_v.Sum()); };
    void            Clip(const double min_value, const double max_value)                { _v.Clip(min_value, max_value); };
    vector          CumProd()                                                           { return(_v.CumProd()); };
    vector          CumSum()                                                            { return(_v.CumSum()); };
    double          Prod(const double initial = 1.0)                                    { return(_v.Prod(initial)); };
    double          Ptp()                                                               { return(_v.Ptp()); };
    double          Percentile(const int percent)                                       { return(_v.Percentile(percent)); };
    double          Quantile(const int percent)                                         { return(_v.Quantile(percent)); };
    double          Median()                                                            { return(_v.Median()); };
    double          Average()                                                           { return(_v.Average()); };
    double          Std()                                                               { return(_v.Std()); };
    double          Var()                                                               { return(_v.Var()); };
    double          CorrCoef(const vector& v)                                           { return(_v.CorrCoef(v)); };
    vector          Correlate(const vector& v, ENUM_VECTOR_CONVOLVE mode)               { return(_v.Correlate(v, mode)); };
    vector          Convolve(const vector& v, ENUM_VECTOR_CONVOLVE mode)                { return(_v.Convolve(v, mode)); };
};







//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
    _vector<double> _v();

    return(INIT_PARAMETERS_INCORRECT);
}


Compile result:


I wont point out all the other errors, as this needs complete revision anyways. -

MetaQuotes, please update the Documentation, maybe add a new section representing vector, complex and matrix objects. - I am a little annoyed, because you dont update the docs to accomodate the pointed out errors in this thread. - Ive contributed quite some work to make it easy for you, still you refuse to do the required updates, and you dont allow us moderators to edit the docs either.


Also it would be nice, if you yould enable us to derive from vector, complex and matrix types. - Example:

template <typename V_Type>
class _vector : public vector<V_Type>
{
    public:
    _vector() :
        vector<V_Type>()
    { };
};

Also, still making it possible to pass these derived objects into API-Functions that tyke in the base types.

Documentation on MQL5: Language Basics / Data Types / Matrices and vectors
Documentation on MQL5: Language Basics / Data Types / Matrices and vectors
  • www.mql5.com
Matrices and vectors - Data Types - Language Basics - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

Asking myself, if this is intentional, or maybe a bug.


According to documentation, it is possible to use initializer lists on structs and classes, as long as they do not have an explicit constructor.

https://www.mql5.com/en/docs/basis/types/classes#class

But this wont work, though, docs do not state dynamic arrays are a show stopper on initialization lists.

struct _test
{
    public:
    double arr[];
};


//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
    _test test_me = { { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 } };

    return(INIT_FAILED);
};

Result:



For confirmation, this seems to be a bug, see following example:



struct _test_dynamic
{
    public:
    double arr[];
};

struct _test_static
{
    public:
    double arr[8];
};



//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
    _test_dynamic   test_me_A = { { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 } };
    _test_static    test_me_B = { { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 } };

    return(INIT_FAILED);
}


Why? - Because per definition, and as figured here:

https://www.mql5.com/en/forum/445076/page2#comment_46566076

An array initialized with an initializer list is static and not dynamic. - This would conclude, the array in _test_dynamic should be implicit declared as a static array. (Or better, resized to  the initializer list size, and have the property dynamic)

EDIT:

Changed first code listing, added brackets to the initialization list, as required for addressing the array inside the struct. (Result is the same)

Documentation on MQL5: Language Basics / Data Types / Structures, Classes and Interfaces
Documentation on MQL5: Language Basics / Data Types / Structures, Classes and Interfaces
  • www.mql5.com
Structures, Classes and Interfaces - Data Types - Language Basics - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Dominik Egert #: Why? - Because per definition, and as figured here:
    _test test_me = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 };
That is the initialization list for an array, but you have only a single variable.