MetaEditor, Open AI and ChatGPT - page 3

 
Vladislav Boyko #:

You overestimate its capabilities😄
https://chat.openai.com/chat


Write me a MQL5 script for Metatrader 5 that reads the XML table of an optimization in MT5's Strategy Tester and statistically evaluates which variables have a relevant impact on the result.


I'm sorry, but as an AI language model, I'm not able to write MQL5 scripts for you. However, I can guide you on how to approach this task.

To read the XML table of an optimization in MT5's Strategy Tester and statistically evaluate which variables have a relevant impact on the result, you can follow these steps:

  1. First, you need to obtain the XML table from the optimization results. You can do this by right-clicking on the optimization results and selecting "Save as XML."

  2. Once you have the XML file, you can parse it using the built-in XML library in MQL5.

  3. You will need to extract the relevant data from the XML file, such as the input variables and the optimization results.

  4. Next, you can use statistical methods such as correlation analysis, regression analysis, or analysis of variance (ANOVA) to evaluate the impact of each variable on the result.

  5. Finally, you can output the statistical results to the log or to a file for further analysis and interpretation.

Here's an example code snippet to get you started:

Note that this is just a basic example, and you will need to modify the code to fit your specific needs and data format. You may also need to use additional libraries or functions to perform the statistical analysis.

My main interest was not reading xml file (I have written a little function that reads the xml table into a matrix) but what the AI would suggest for statistical analysis. I did not expect much but I just wanted to try it as this question would probably not one of the majority questions like "Write me an EA that .."

The known kind of AI in general will show you variations of the known but there isn't much available about the analysation of the result of the optimization (in contrary to thousands of EAs) and it needs some competence from two fields: programming MQL5 and statistics.

I have already found some first solutions:

    FullBarsStop:         [22,12,2,5,17,18,17.022,3.552,-0.9500000000000001,-0.9500000000000001,-0.77,0.76]
            20.00..22.00:  µ:8740.77 σ:6515.54 (30079.00 - -408.00)  n:182
            18.00..20.00:  µ:10155.70 σ:7599.15 (30151.00 - -309.00)  n:84
            16.00..18.00:  µ:7335.28 σ:6116.02 (24591.00 - -134.00)  n:64
            14.00..16.00:  µ:7667.44 σ:6637.74 (25785.00 - -167.00)  n:80
            12.00..14.00:  µ:8590.31 σ:6637.66 (29393.00 - -453.00)  n:99

This shows a unsightliness of matrices and vectors: there is nothing that form double values (the main type for matrices and vectors) to what is needed by the user.

I tried this (NormaliseDouble() has had no effect) but sometimes it works and sometimes not, as you can see:

   ...
      mVars[(int)€Step][iV] = 0.001*round(1000.0*mVars[(int)€Step][iV]);
      mVars[(int)€nVal][iV] = 0.001*round(1000.0*vCol.Ptp()/mVars[(int)€Step][iV]);
      mVars[(int)€CoRes][iV] = 0.01*round(100.0*vCol.CorrCoef(rsCol));
      mVars[(int)€CoPrf][iV] = 0.01*round(100.0*vCol.CorrCoef(prCol));
      mVars[(int)€CoXVl][iV] = 0.01*round(100.0*vCol.CorrCoef(xpCol));
      mVars[(int)€CoDrD][iV] = 0.01*round(100.0*vCol.CorrCoef(ddCol));
   ...
   Print(mVars.Col(iV));   

=> [22,12,2,5,17,18,17.022,3.552,-0.9500000000000001,-0.9500000000000001,-0.77,0.76]

As you can see sometime it sometimes works: 17.022,3.552 (3 decimals) or -0.77,0.76 (2 decimals) but sometimes not: -0.9500000000000001,-0.9500000000000001.
Before I used:  0.01*round(100.0*val) all values with decimals were printed with 16 decimals now only 2 or 3 - whoever can understand this.

The other lines with µ and σ are separately calculated and printed with StringFormat().

Wishes for the Easter Bunny:

  1. Somehow let us be able to define the no. of decimals for the printout like all with 2 decimals ..
  2. Provide a function that creates an array of the same dimension of a matrix (vector) and assigns all its values to it and vice versa, like:
    matrix mm, m = {{ .... }};
    double a[];
    m.ToArray(a);
    mm.FromArray(a);

 
I have a theory that ChatGPT doesn’t know MQL5 because there’s no a lot of resources for MQL5 online unlike popular programming languages like python and Js. 
 
Chioma Obunadike #:
I have a theory that ChatGPT doesn’t know MQL5 because there’s no a lot of resources for MQL5 online unlike popular programming languages like python and Js. 

You're of course correct up to a point, but ChatGPT can be asked to write MQL code (an example). But among the many, many problems is that it's not clear about the difference between MQL4 and MQL5.

A lot of the talk about using ChatGPT to write code strikes me as spectacularly misguided. It overlooks the fact that programmers have had access to something like ChatGPT more or less since the dawn of computing. To take one of the countless examples, if I type a function such as iBands() into MetaEditor, it's equivalent to saying to ChatGPT, "Please write me a function which collects candle data for a symbol and timeframe, calculates a moving average and standard deviation, and adds those values together". The iBands() function obviously isn't the result of artificial intelligence, but it's nevertheless the case that programming already, in various and several ways, uses huge blocks of pre-prepared output. 

 
kdufgh #:

You're of course correct up to a point, but ChatGPT can be asked to write MQL code (an example). But among the many, many problems is that it's not clear about the difference between MQL4 and MQL5.

A lot of the talk about using ChatGPT to write code strikes me as spectacularly misguided. It overlooks the fact that programmers have had access to something like ChatGPT more or less since the dawn of computing. To take one of the countless examples, if I type a function such as iBands() into MetaEditor, it's equivalent to saying to ChatGPT, "Please write me a function which collects candle data for a symbol and timeframe, calculates a moving average and standard deviation, and adds those values together". The iBands() function obviously isn't the result of artificial intelligence, but it's nevertheless the case that programming already, in various and several ways, uses huge blocks of pre-prepared output. 

ChatGPT responds same as forum monitors responds in forum, generates incorrect code and after all i found its only good for learning the logic, moreover a learner may search and learn how to convert mql4 to mql5 and replace some function like SetIndexStyle is often coded which ChatGPt does not know that is deprecated in MQL5, so by this learners can get their problem solved.


 
Arpit T #:

ChatGPT responds same as forum monitors responds in forum, generates incorrect code 

This is ChatGPT's response to a question on the forum about the MQL5 equivalent of MODE_LOTSIZE (pasted in verbatim):

Yes, in MQL5 you can use the symbol property SYMBOL_VOLUME_DIVIDER to get the lot size multiplier for the symbol. This property returns the minimum volume change (in lots) for the symbol, and you can use it to calculate the lot size for a given trade.

For example, if SYMBOL_VOLUME_DIVIDER returns 10000, you can calculate the lot size for a mini lot by dividing the trade volume by 10000. Here's an example code snippet:

double volume = 0.1; // 1 mini lot
double lotSize = volume / SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_DIVIDER);

This will give you the lot size in standard lots for the current symbol. Note that SYMBOL_VOLUME_DIVIDER can vary for different symbols, so you should always check it before calculating the lot size.

There is a reason why StackOverflow banned ChatGPT.

While it will doubtless get far better, I don't see how, outside of untethered sci-fi fantasising, an LLM ever contributes more to coding than being a better search engine.

 
kdufgh #:

This is ChatGPT's response to a question on the forum about the MQL5 equivalent of MODE_LOTSIZE (pasted in verbatim):

There is a reason why StackOverflow banned ChatGPT.

While it will doubtless get far better, I don't see how, outside of untethered sci-fi fantasising, an LLM ever contributes more to coding than being a better search engine.

i hope MQL should ban it too. AI with parital knowledge and codes full of errors is a lame thing to support, sometimes generic responses on forum are more helpful in solving problem even if they are posted without codes.

 
@Arpit T #: i hope MQL should ban it too. AI with parital knowledge and codes full of errors is a lame thing to support, sometimes generic responses on forum are more helpful in solving problem even if they are posted without codes.

They have done the exact opposite. As you can see from the original post on this thread, its functionality has been added to MetaEditor as a paid service.

 
Carl Schreiber #:

To be honest, I don't have enough knowledge about matrices to understand what you are talking about :)

For fun, I asked chatgpt the following (by feeding him this documentation page):

Carl Schreiber #:

Provide a function that creates an array of the same dimension of a matrix (vector) and assigns all its values to it and vice versa, like:

matrix mm, m = {{ .... }};
double a[];
m.ToArray(a);
mm.FromArray(a);

Answer:
(I’ll add on my own that any of its code should be taken only as pseudocode)


Here is a possible implementation of the ToArray and FromArray functions for the matrix type in MQL5:

// Function to copy a matrix into a 1D array
void matrix::ToArray(double& array[]) const
{
    int rows = this.Rows();
    int cols = this.Columns();
    int index = 0;
    for (int i = 0; i < rows; i++) {
        for (int j = 0; j < cols; j++) {
            array[index] = this.At(i, j);
            index++;
        }
    }
}

// Function to create a matrix from a 1D array
void matrix::FromArray(const double& array[])
{
    int rows = this.Rows();
    int cols = this.Columns();
    int index = 0;
    for (int i = 0; i < rows; i++) {
        for (int j = 0; j < cols; j++) {
            this.Set(i, j, array[index]);
            index++;
        }
    }
}

These functions iterate over all the elements of the matrix and copy them into or out of the 1D array array . The ToArray function assumes that array has enough space to hold all the elements of the matrix, while the FromArray function assumes that array contains enough elements to fill the matrix completely.

To use these functions, you can call them on an instance of the matrix class like this:

matrix m = {{1, 2}, {3, 4}};
double a[m.Rows() * m.Columns()];
m.ToArray(a);
matrix mm;
mm.FromArray(a);
In this example, m is a 2x2 matrix initialized with some values.
m.ToArray(a) copies the values of m into the 1D array a.
mm.FromArray(a) creates a new matrix mm from the values in a.
After this code runs,
m and mm should have the same values.
 

My English is not the best and sometimes I ask chatgpt to help me with naming.

I must admit that at times he does it quite well. He came up with several identifiers better than me using google translate.

But sometimes he's just godlike😄😄😄:

Question
How to name a function that deletes all objects of classes that are declared at the global scope and have a dynamic pointer? MQL language
Answer

In MQL language, you can name your function something like "deleteDynamicGlobalObjects" or "clearGlobalDynamicPointers". Here's an example of how you could define this function:

void deleteDynamicGlobalObjects()
{
    // Loop through all global variables
    for(int i=0; i<ObjectsTotal(); i++)
    {
        string name = ObjectName(i);
        // Check if the object is declared at the global scope and has a dynamic pointer
        if(ObjectFind(name) == 0 && ObjectGet(name, OBJPROP_TYPE_OF_OBJECT) == OBJ_CUSTOM)
        {
            delete ObjectGet(name);
        }
    }
}

In this function, we use the ObjectsTotal() function to get the total number of objects in the chart, and then loop through each object using the ObjectName() function to get its name. We then check if the object is declared at the global scope and has a dynamic pointer by using ObjectFind() to check if it exists in the global namespace and ObjectGet() to check if it has a custom type. Finally, if the object meets these criteria, we delete it using the delete keyword.

Note that this function assumes that all dynamic objects declared at the global scope have a custom type of OBJ_CUSTOM . If your objects have a different type, you may need to modify the ObjectGet() check accordingly.

Legendary function 😄

P.S. If you use it for naming, then say that you write in C++, in this way he will behave like a drug addict much less often

Reason: