Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 939

 
Nikita Chernyshov:

The question is purely one of aesthetics.

How do I make it so that there is a picture of its own here? MT4



#property icon
 
Artyom Trishkin:

Yes, I know that property, thank you. But it implies that the icon has to be at the user. Is there any way around this? So that the person only downloaded ex4 and my image is displayed to him?

 
Koldun Zloy:

If you have specific array cells allocated to each type, then make a structure instead of an array.

I thought of doing that, but I lost the link where the person put the elements from the structure into the structured array. He declared a structure and then created an array and under each number was stored type int string double, but there he had an array with only one different element in each cell, so I thought it was possible here too, but apparently not.

 
Igor Makanu:

What has been cut, exactly?

#include "stdafx.h"
#include <conio.h>
#include <iostream>

using std::cout;
using std::endl;
using std::cin;

template<typename T> void Fun(T a[],size_t m=2,size_t n=2, T r=0)
{
        for ( size_t i = 0; i < m; i++ )
    {
        for ( size_t j = 0; j < n; j++ ) 
                        {
                    (a[i * n + j ])=(a[i * n + j ])*5;
                        cout <<(a[i * n + j ])<<" "<<endl;
                    }
        }cout<<endl; 
}

int _tmain(int argc, _TCHAR* argv[])
{
        int     mas[6]={1,2,3,4,5,6};
        double mas1[2][2]={{1.4,4.2},{2.8,6.7}};//int //{{},{}};
        int mas2[2][2][2];

        Fun(*mas1);//Для 2умерного массива передача по ссылке, но в mql4 все массивы передаются по ссылке 
        Fun((mas),6,1);
        for(int i=0;i<2;i++)
        {for(int t=0;t<2;t++)
        {cout<<mas1[i][t]<<" "<<endl;}}
        _getch();
        return 0;
}

In this example I passed a 2-dimensional and a 1-dimensional array into the function, and by the way this is my code.

Here's another example of what mql4 can't do.

#include <iostream>
#include <variant>
 
using double_bool_int = std::variant<double, bool, int>;
 
int main()
{
    const size_t len = 15 u;
    double_bool_int* arr = new double_bool_int[len];
 
    {
        size_t idx = 0 u;
        for (; idx < 5 u; ++idx)
            arr[idx] = static_cast<double>(0.5 * idx);
        for (; idx < 10 u; ++idx)
            arr[idx] = static_cast<bool>(idx & 1 u);
        for (; idx < 15 u; ++idx)
            arr[idx] = static_cast<int>(2 * idx);
    }
    for (auto it = arr; it != arr + len; ++it)
    {
        if (const auto i = std::get_if<int>(it); i)
            std::cout << "int " << *i << "\n";
        else if (const auto d = std::get_if<double>(it); d)
            std::cout << "double " << *d << "\n";
        else if (const auto b = std::get_if<bool>(it); b)
            std::cout << "bool " << std::boolalpha << *b << "\n";
    }
    
    delete[] arr;
    return 0;
}

Which of these can mql4 or here's an example

double f(double n, ...)    //--заголовок с переменным числом параметров
{   double *p = &n;        //--установились на начало списка параметров
    double sum = 0, count = 0;    
    while (*p)         //--пока аргумент не равен нулю
    { sum+=(*p);         //--суммируем аргумент
      p++;             //--«перемещаемся на следующий аргумент
      count++;         //--считаем  количество аргументов
    }
    return ((sum)?sum/count:0);    //--вычисляем среднее
}
 
Nikita Chernyshov:

Yes, I know that property, thank you. But it implies that the icon has to be at the user. Is there any way around this? So that the person only downloaded ex4 and my image is displayed to him?

Attach the picture with a resource.
 
Nikita Chernyshov:

Yes, I know that property, thank you. But it implies that the icon has to be at the user. Is there any way around this? So that the person only downloaded ex4 and my image is displayed to him?

It doesn't.

 
Alexey Viktorov:
Attach a picture with a resource.

For an icon, it won't work.

#property icon already packs the icon in ex

 
Seric29:

and that's my code, by the way.

Well, if it's your code, then compile it into a .dll and connect it to MQL, two clicks of work, three months of incomprehensible discussion
 
Artyom Trishkin:

Doesn't imply.

Thanks, figured it out, it's been an eye-opener.

 
Igor Makanu:
Well, if this is your code, then compile it into a .dll and connect it to MQL, the "two clicks" work, incomprehensible discussion for three months

The problem is that I apply templates to all functions that take arrays, and export and import of template functions is not possible it will have to duplicate functions for each type, the same situation with dimensionality mql does not want to give them just like that and again I have to duplicate them by dimensionality turns out a kind of overload but add additional arguments is not necessary nevertheless this is also excessive code, as for increasing function arguments mql also will not give just the data I have to duplicate functions do overload So I don't think it's worth it, I thought about writing my own language but then again I wrote 15% of my robot and spent more than a year to calibrate everything and make it as universal as possible and provide fast performance and 3 years for calculations. I just don't have enough life to write my own language. So there you go.