Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 73
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
Artem, you are wrong. The array declared on a global level is visible in all parts of the program and it isn't necessary to pass it somewhere from somewhere. You just fill it in one place in the program, and sort it in another, and read it in the third, it doesn't matter.
The same function can successfully sort and/or search data in different arrays. Right? And if so, it's better to pass the array by reference - for the future. And when calling the function, it won't hurt to see what array it will work with.
I'm just making these considerations. Where am I wrong?
The same function can successfully sort and/or search data in different arrays. Right? And if so, it's better to pass the array by reference - for the future. And when calling the function, you should also be able to see the array it will work with.
I'm only right about that. Where is wrong?
Got it. Your advice is for lego-programmers. You don't do this perversion yourself.
That leaves one thing wrong, in that the array must be declared globally.
I'm glad we understand each other.
Got it. Your advice is for lego programmers. You don't do such perversions yourself.
Then one thing remains, wrong about the array having to be declared globally.
Glad we understand each other.
My point in this context is this:
For this reason, it would be better to have global arrays - for closed and open orders and positions. Once on a new tick, we pass the necessary amount of orders/positions once, filling two arrays with them. And then we get all the necessary data from them on the same tick. Note that not only the last closed/open order/position and all its data are calculated, but also all parent and child ticks of all positions are searched in case of partial closing. Accordingly, at any time I can see what ticket this or that position is from, if it has been partially closed more than once - all this already works in a class that runs in a timer. I have many other data I need with a small total number of cycles. The required depth of history for arrays is set for the tester.
And so on and so forth ...
In this context, my point is this:
For this reason, it would be better to have global arrays - for closed and open orders and positions. Once on a new tick, we pass the necessary amount of orders/positions once, filling two arrays with them. And then we get all the necessary data from them on the same tick. Note that not only the last closed/open order/position and all its data are calculated, but also all parent and child ticks of all positions are searched in case of partial closing. Accordingly, at any time I can see which ticket originated from one or another position, if it has been closed partially more than once - all this already works in a class that runs in a timer. I have many other data I need with a small total number of cycles. For the tester, the desired depth of history is set for the arrays.
And so on and so forth ...
So we don't quite understand each other.
If the array is global, why pass it into a function by reference if it's already visible inside this function?
Then we don't quite understand each other.
If the array is global, why pass it into a function by reference, if it is already visible within this function?
Function overloading - there is such a notion ;)
If you need to do the same actions with different arrays in one function, then...
However - we are discussing different special cases...
Function overloading - there is such a concept ;)
If you need to do the same actions with different arrays in one function, then...
However - we are discussing different special cases...
Well, thank goodness I get your thoughts. But they are very much like advice to lego programmers.
It would be very strange to have a huge number of 100% working functions in stock and write them all over again every time. This is not advice for building houses out of dice. It's advice to accumulate your own function libraries and classes. And what's wrong with one function handling multiple arrays depending on which one is passed to it by reference? And what's wrong with function templates?
If you have code for sorting an array, why write a separate function for every array type? You can simply overload and sort any type. How do you think ArraySort() works? You pass different types of arrays there, and on an output you receive the sorted one which was passed - or meta quotas also lego-coders or what?
It would be very strange to have a huge number of 100%-working functions in stock and write them all over again every time. This is not advice for building houses out of cubes. It's advice to accumulate your own function libraries and classes. And what's wrong with one function working with multiple arrays depending on which one is passed to it by reference? And what's wrong with function templates?
If there is code for sorting an array, why should we write a separate function for each type of array? You can just do an overload and sort any type. How do you think ArraySort() works? You pass different types of arrays there, and the output is a sorted one, which you passed - or metaquotes also lego-coders, or what?
The main thing is not to come to this.
https://www.mql5.com/ru/forum/165468/page3#comment_3978059
The main thing is not to come to this.
https://www.mql5.com/ru/forum/165468/page3#comment_3978059
there is a variable
int Level = 0;
While the program is running, it is constantly changing. Help me write a condition: if Level has NOT changed, do nothing, if Level has changed (it doesn't matter if it has changed more or less), do some action { operator }