Questions from Beginners MQL5 MT5 MetaTrader 5 - page 731
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Isn't 10,000 x 10,000 two-dimensional?
and all that...
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?
What is braking in this code is not writing of an array but a loop in a loop.
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
{
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)))
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)))
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.
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.
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 работает
... здесь работа с массивом и основной код
}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:
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); // а при такой записи ругается // это тоже лишнее
}
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.
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
How do I reverse it now? It needs to be in descending order, it's sorting lots.
Here it sorts in ascending order
How do I reverse it now? You need it in descending order, it sorts the lots.
And the dumbest option is to rewrite the entire array in the reverse order. Is it worth it?
Here it sorts in ascending order
How do I reverse it now? You need it in descending order, it sorts the lots.
What if, after sorting, you change the indexing order using ArraySetAsSeries?
Then it goes like this: