In MQL5 there is always room for an exploit ! ;) - page 3

 
mql5:
Briefly.
Functions of system libraries for x86 (32 bits) processes have a special wrapper through which they are passed to x64, executed and returned back to x86.

64 bit Windows has a folder called SysWOW64. This folder is intended for 32-bit applications launched in the 64-bit OS, while regular 64-bit libraries and drivers are stored in the System32 folder. If the program is launched as a 32-bit one, references to the System32 folder are redirected to SysWOW64.

To make it brief, the issue of 32/64 bits has become acute in MT5.

this is a very important issue and it's about time it was addressed.

or add a libraries64 folder so that the terminal knows where to get the libraries from
or add some way of dispersing DLLs into the Windows folders System32/SysWow64
or let them #ifdef

https://www.mql5.com/ru/forum/6729#comment_199764

ZS.
application to SD #381730

 
MetaDriver:

Array of any dimensionality (for clarity, let's say, limit it to ^16).

The dimensionality is set at creation by the number of parameters, as for normal arrays.

XXArray  xx2(5,7),  xx5(12,12,16,16,8);

Indexers should work for all dimensions ( A[i][j][k][n][m]....)

Well, since the community is silent, I'll continue...

An outline of an N-dimensional (double) array class and a test to test it.

The dimensionality is described by (int) array in the constructor.

//+------------------------------------------------------------------+
class CNXdouble
{
        double                 value[];
        int                    size[];
        int                    index;
        int                    ivalue;
public:
                               CNXdouble(const int &n[]);
                              ~CNXdouble()   { ArrayFree(value); ArrayFree(size);}
        double      operator[]   (long x_);
        CNXdouble  *operator[]  (int x_)      { ivalue+=x_*size[index++]; return(GetPointer(this));}
        void         operator=    (double d)    { value[ivalue]=d; index=0; ivalue=0;}
};
//+------------------------------------------------------------------+
CNXdouble::CNXdouble(const int &n[])
{
        int m=1, k=ArraySize(n);
        ArrayResize(size,k);
        size[k-1]=1;
        for(int i=k-2; i>=0; i--) size[i]=n[i+1]*size[i+1];
        for(int i=0; i<k; i++) m*=n[i];
        ArrayResize(value,m);
        index=0;
        ivalue=0;
}
//+------------------------------------------------------------------+
double CNXdouble::operator[] (long x_) 
{
        index=0;
        int i=ivalue;
        ivalue=0;
        return(value[i+(int)x_]);
}
//+------------------------------------------------------------------+
void OnStart()
{
   int n[]={2,3,4,2};      //описание 4-х мерного массива
   int a1=n[0], a2=n[1], a3=n[2], a4=n[3];
   CNXdouble d2(n);
   //запись в массив
   int c=0;
   for(int i=0; i<a1; i++)
       for(int j=0; j<a2; j++) 
           for(int x=0; x<a3; x++) 
               for(int y=0; y<a4; y++)
                   d2[i][j][x][y]=(double)c++;
   //чтение из массива
   string s="";
   for(int i=0; i<a1; i++)
       for(int j=0; j<a2; j++) 
           for(int x=0; x<a3; x++)
               for(long y=0; y<a4; y++)
                   s+=(string)d2[i][j][x][y]+" ";
   Print(s);
}
//+------------------------------------------------------------------+
Files:
 

The second variant is an N-dimensional (double) array. The structure of the array is also specified in the constructor by another (int) array.

This variant is a bit faster than the previous one. And in this variant it is easier to create operations with subarrays.

class CNArray
{
        CNArray                    *array[];
        double                      value[];
        bool                        last;
        int                         ivalue;
public:
                                   CNArray(const int &n[]);
                                  ~CNArray();
        double      operator[]      (long x);
        CNArray*   operator[]      (int x);
        void        operator=       (double d) { if(last)value[ivalue]=d;}
};
//+------------------------------------------------------------------+
CNArray::CNArray(const int &n[])
{
        int k=ArraySize(n);
        if(k>1)
        {
                ArrayResize(array,n[0]);
                int n1[];
                ArrayResize(n1,k-1);
                for(int i=0; i<k-1; i++) n1[i]=n[i+1];
                for(int i=0; i<n[0]; i++) array[i]=new CNArray(n1);
                ArrayFree(n1);
                last=false;
        }else if(k==1)
        {
                ArrayResize(value,n[0]);
                last=true;
        }
}
//+------------------------------------------------------------------+
CNArray::~CNArray()
{ 
        if(!last)
        {
                int n=ArraySize(array);
                for(int i=0; i<n; i++) delete array[i];
                ArrayFree(array);
        }else ArrayFree(value);
}
//+------------------------------------------------------------------+
double CNArray::operator[](long x) 
{
        if(last) return(value[(int)x]); else return(0);
}
//+------------------------------------------------------------------+
CNArray* CNArray::operator[](int x)
{ 
        if(last)
        {
                ivalue=x; 
                return(GetPointer(this));
        }else return(array[x]);
}
 
Yurich:

The second variant is an N-dimensional (double) array. The structure of the array is also specified in the constructor by another (int) array.

This variant is a bit faster than the previous one. And in this variant, it is easier to create operations with subarrays.

Yurich, you are a cool guy. I was distracted from the forum for a couple of days, and you have already made a couple of variants.

First impression - first variant is fraught with glitches at incorrect call with less number of indexes: for example double x=A[i][j][k]; "three-dimensional call" for four-dimensional array will return double as no big deal, but from any other position of array which user wanted.And it's not obvious how to trace and handle such errors. But the first implementation's indisputable advantage is economy in memory. The second way is much more wasteful. But, as you have correctly noticed, you can try to get through to subarrays in it and all the difficulties are quite manageable in this case.

I've got some ideas, but I won't get to free time until the night before, if I get there at all. But we'll get there, I promise. :)

--

Basic idea: use one more class, something like "left indexes controller", and the rightmost index to process by main class (if it will work. If not, then one more class for the right index). In doing so, the base array double (one-dimensional and the only one) should be made a member of the main class CNArray. Something like this.

 
MetaDriver

Tx. First impression - the first variant is fraught with glitches at incorrect call with less number of indexes: i.e. for example double x=A[i][j][k]; "three-dimensional call" for four-dimensional array will return double as if nothing had happened, but at the same time from the array position which user wanted. Moreover, to track down and handle such errors is not visible in what way.

I've been playing around with Yurich's first method, and it seems to be possible to control the array rank this way:

class DinArr_Double{
        double                 value[];
        int                    size[];
        int                    index;
        int                    ivalue;
        int                    range;
        bool                   checkerror;
public:
                               DinArr_Double(const int &n[]);
                              ~DinArr_Double()   { ArrayFree(value); ArrayFree(size);}
        double          operator[](long x_);
        DinArr_Double*  operator[](int x_);
        void            operator= (double d)    { value[ivalue]=d; index=0; ivalue=0;}
};
//+------------------------------------------------------------------+
DinArr_Double::DinArr_Double(const int &n[]){
        int m=1, k=ArraySize(n);
        range = ArraySize(n);
        ArrayResize(size,k);
        size[k-1]=1;
        for(int i=k-2; i>=0; i--) size[i]=n[i+1]*size[i+1];
        for(int i=0; i<k; i++) m*=n[i];
        ArrayResize(value,m);
        index=0;
        ivalue=0;
        checkerror = false;
}
//+------------------------------------------------------------------+
double DinArr_Double::operator[](long x_){
        index=0;
        int i=ivalue;
        ivalue=0;
        return(value[i+(int)x_]);
}
//+------------------------------------------------------------------+
DinArr_Double*  DinArr_Double::operator[](int x_){
      ivalue+=x_*size[index++];
      if(index!=range)checkerror = true; else checkerror = false;
      return(GetPointer(this)); } //+------------------------------------------------------------------+ void OnStart(){    int n[]={2,3,4,2};      //описание 4-х мерного массива    int a1=n[0], a2=n[1], a3=n[2], a4=n[3];    DinArr_Double d2(n);    //запись в массив    int c=0;    for(int i=0; i<a1; i++)        for(int j=0; j<a2; j++)            for(int x=0; x<a3; x++)                for(int y=0; y<a4; y++)                    d2[i][j][x][y]=(double)c++;    //чтение из массива    string s="";    for(int i=0; i<a1; i++)        for(int j=0; j<a2; j++)            for(int x=0; x<a3; x++)                for(long y=0; y<a4; y++)                    s+=(string)d2[i][j][x][y]+" ";    Print(s); } //+------------------------------------------------------------------+
 

Task:

- To pass an array of numbers from the Expert Advisor to the indicator.


Requirements.

Do not use
- chart events,
- files,
- global variables (also known as files),
- dll

Документация по MQL5: Основы языка / Переменные / Глобальные переменные
Документация по MQL5: Основы языка / Переменные / Глобальные переменные
  • www.mql5.com
Основы языка / Переменные / Глобальные переменные - Документация по MQL5
 
sergeev:

Task:

- To pass an array of numbers from the Expert Advisor to the indicator.


Requirements.

- Do not use chart events, files, dll for data transfer

Willglobal variables of the terminal work?
Документация по MQL5: Основы языка / Переменные / Глобальные переменные
Документация по MQL5: Основы языка / Переменные / Глобальные переменные
  • www.mql5.com
Основы языка / Переменные / Глобальные переменные - Документация по MQL5
 
Then the named channels remain.
 
sandex:
Then the named channels remain.
who is the server?
 
sergeev:

Task:

- To pass an array of numbers from the Expert Advisor to the indicator.


Conditions.

Do not use
- chart events,
- files,
- global variables (aka files),
- dll

There is no one to do it :)

Then I propose another variant - use subchart andChartSetString()andChartGetString() functions.