Questions from Beginners MQL5 MT5 MetaTrader 5 - page 731

 
Vitalie Postolache:

Isn't 10,000 x 10,000 two-dimensional?

double arr[10000][10000];

and all that...

Top2n:
Well yes it's two-dimensional, that's not how I put it, apparently it's not a matrix but an array. Does a matrix imply multidimensionality?
I agree. That's not what was said, plus it was misunderstood.

What is braking in this code is not writing of an array but a loop in a loop.
 
Alexey Viktorov:
Agreed. That's not what was said and was misunderstood.

What is braking in this code is not writing of the array but the loop in the loop.

Is it necessary to port to another programming environment, or is this not a common problem for all types of languages? What can be the solution for speeding up?

If one loop and increase the value of the variable from the deleted loop

         for(int q=0; q<ARRAY_SIZE_X*ARRAY_SIZE_Y; q++) // Перебор по периоду, колонка X
                 {
                  int arr++
                  if(arr=ARRAY_SIZE_X) {z++;arr=0;}

                  arra[q]=sm.d[q].m[nBar-z];                // M(I) SMA              
                 }
         //--- запишем данные массива в конец файла FileTell IsFileLineEnded
               FileSeek(handle,0,SEEK_END);
               FileWriteArray(handle,arra);


I might have checked it but I don't want to trouble the computer - if it won't speed up, extra stress will be put on the hard drive again)))

 
Top2n:

Is it necessary to transfer to another programming environment, or is this not a common problem for all types of languages? What can be the solution for speeding up?

If one loop and increase value of variable from deleted loop in it, will it speed up?

I could check it, but I don't want to torture the computer, if it is not accelerated, it will put extra stress on the hard drive again)))

And you can't write the array after the loop? You can do it only on each line? I'm referring to the first variant, where the loop is in the loop.
 
Vitalie Postolache:
Can't you write the array after the loop? Is it possible to do it only on each line? I'm referring to the first variant where the loop is in the loop.
An array of this size would not fit into the allocated RAM.

Of course, you can additionally insert a counter and write to this counter, not each line separately, but it is unlikely to speed up the process so much that it will be noticeable without measuring.
 
Alexey Viktorov:
An array of this size wouldn't fit into the allocated RAM.

Of course, you can additionally insert a counter and record by this counter, not each row separately, but it's unlikely to speed up the process so much that will be noticeable without measuring.

Please tell me, the documentation says (and so does the compiler) that:"AS_SERIESflag cannot be set for multidimensional arrays"

Question: How can I sort an array in mql5?

void Func()
{
double m[][3];

if(условия)
  {
   // много кода
         c++;
         ArrayResize(m, c);
         m[c-1][0]= Lots();
         m[c-1][1]= Ticket();
         m[c-1][2]= Profit();
  }
 BySort(m); // передаём в функцию "BySort"
}

void BySort(double &mas[][3])
{
// Сортируем по размеру лота от большего к меньшему
  ArraySort(mas);
  ArraySetAsSeries(mas,true); // при такой записи mql5 ругается, в mql4 работает

 ... здесь работа с массивом и основной код 

}
 
Vitaly Muzichenko:

Please advise, the documentation says (and so does the compiler) that:"TheAS_SERIESflag cannot be set for multidimensional arrays".

Question: how to sort the array:

double m[][3];

if(условия)
 {
// много кода
         c++;
         ArrayResize(m, c);
         m[c-1][0]= Lots();
         m[c-1][1]= Ticket();
         m[c-1][2]= Profit();
 }

void BySort(double &mas[][3])// выделенное лишнее
 {
// Сортируем по размеру от большего к меньшему
  ArraySort(mas, WHOLE_ARRAY, 0, MODE_DESCEND); // вот это не работает в mql5

  ArraySort(mas);
  ArraySetAsSeries(mas,true);
// а при такой записи ругается // это тоже лишнее
 }
AS_SERIES and sorting are completely different concepts.

1 - it changes direction of array cells indexing without changing their contents and 2 - it changes cells contents without changing their indexing so that they are sorted in ascending or descending order.

Additionally, the documentation says that the array can only be sorted by the first dimension.
 
Alexey Viktorov:
AS_SERIES and sorting are completely different concepts.

1 - changes direction of array cells indexing without changing their contents, and 2 - without changing indexing changes cell contents so that they are sorted in ascending or descending order.

Additionally, the documentation says that the array can only be sorted by the first dimension.

Here it sorts in ascending order

ArraySort(mas);

How do I reverse it now? It needs to be in descending order, it's sorting lots.

 
Vitaly Muzichenko:

Here it sorts in ascending order

ArraySort(mas);

How do I reverse it now? You need it in descending order, it sorts the lots.

Wow. This is my first time looking at sorting in mql5. I am using mql4 from memory. If this is the case, you can reverse the reading loop. If you need to search for a specific value, it will return the array index, no matter how you sort it.

And the dumbest option is to rewrite the entire array in the reverse order. Is it worth it?
 
Vitaly Muzichenko:

Here it sorts in ascending order

ArraySort(mas);

How do I reverse it now? You need it in descending order, it sorts the lots.

And if after sorting change the indexing order using ArraySetAsSeries?
 
Vitalie Postolache:
What if, after sorting, you change the indexing order using ArraySetAsSeries?

Then it goes like this: