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

 
ANDREY:

Got the general idea...as far as I'm concerned. Thanks for the tip. If you don't mind, could you tell me what dollar sign means before array name $ array[] and before value $var

I have a feeling it's not from mql4 for some reason.

yes, it's not frommql, but the meaning is the same

 
Aleksei Stepanenko:
In your case, the answer to the main question is interesting: Why do you need to do sorting every minute? How can your idea be implemented in a more economical way?

The code I posted is just an example of the problem I couldn't solve. In the real code the sorting will have to be done on every tick in a column of size 20 to 30 elements. I have a quad core processor and that's why I don't feel any delays in testing so far. Besides, the actual code is not very big either. But I have not yet completely represented my idea in the form of code. When I code it completely, then I will think how to improve it from performance point of view.

And did I get it right, that search for 1000 values in mql takes less time than sorting 1000 array elements or any other operations with arrays? By the way, could you please tell me..... which operations in mql4 take a long time?

Thanks for the help

 
Vitaly Muzichenko:

yes, it is not frommql, but the meaning is the same

And what language is it and am I right to understand that some constructions of this language can be used in mql? I think for the future this information would be useful to me
Thanks for your help.

 
ANDREY:

What language is it and do I understand correctly that some constructions of this language can be used in mql? I think for the future this information would be useful to me
Thanks for your help.

It's php, but I don't think you need to look into it,there areenough answers onmql on this forum too.

 
Vitaly Muzichenko:

It's php, but I don't think you need to look into it,there areenough answers onmql on this forum too.

Got it. Thanks.

 
ANDREY:

Got it. Thank you.

You need to properly think through the logic of what you want the output to be, and then start writing. There are many things that you don't need to count on every tick, but only when the situation changes.

You only need to monitor the change of the situation and do the heavy calculations after that, rather than doing them on every tick unnecessarily.

 
Vitaly Muzichenko:

You need to properly think through the logic of what you want the output to be and then start writing. There are many things that don't need to be calculated on every tick, but only when the situation changes.

To do this, you only need to monitor the change of the situation and then make heavy calculations, rather than doing them on every tick unnecessarily.

I have already thought through the logic and clearly understand what I want to get at the output. I understand Mql4 (and a little bit of Mql5) to the extent that I understand a lot (but not all) of what I need from the manuscripts. And most importantly, I understand almost everything that is explained to me on this forum. I'm trying now to code my conception, but not just any way, but the code should be executed quickly, because I will need to test it on many instruments and on long timeframes. And anyway .... That is right now I'm trying my best to code my concept by trial and error (I have very little coding experience) and at the same time to learn something new and useful for future tries.

 
ANDREY:

But not randomly, but so that code execution takes minimum time

So tell us what sorting is needed for, maybe we can come up with an idea for another implementation.

 
Aleksei Stepanenko:

So tell me what the sorting is for, maybe we can come up with an idea for another implementation.

Thanks for your help. You have intrigued me ..... I think in 1-2 days I will finish a part of real code with sorting and then I will post it here to learn your professional opinion.

And I have one more question about information, that Maxim Kuznetsov gave me in this post. He visits here less often than you, so I'd be grateful if you could explain me something about his code

void Convert_7x2_2x7 (const double &src[7][2],double &dst[2][7]) {

for(int i=0;i<7;i++)

for(int j=0;j<2;j++) {

dst[j][i]=src[i][j];

}

}

I've been studying it carefully and for a long time and this is what came to my mind...

1.This is a user-defined function

2.There is no reference to it in the code above. It is implied in the main code within void OnTick()

3. Only the array indexes will be changed in this code. What happens to the array items' values I can only guess.

What I do not understand is this.

1. If the final execution of this function causes dst[j][i] to get new values of dst[7][2], what was the point of loops? Couldn't dst[j][i] be assigned those index values immediately and explicitly?

2. Did I get it right, that if I change the values of the indexes in this code, the necessary values of the array elements will automatically change into the new cells by themselves?

3. I would be grateful if you could write how this custom function is called.

The subject of arrays is rather new to me, and though this information is not related to my current code, I am sure it will be useful to me in the future. And I like to make reserves for the future by nature. :-)
Thanks for your help.

 

No, it's a long way from being a professional.

double LoY[31][2], Mirror[2][31];

//вызывается так:
ConvertArray(LoY,Mirror);

//все значения строк из массива LoY запишутся в столбцы Mirror,
//условно сказать, массив повернётся
void ConvertArray(const double &src[31][2],double &dst[2][31])
   {
   for(int i=0; i<31; i++) for(int j=0; j<2; j++) dst[j][i]=src[i][j];
   }

Reason: