Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1920
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
These are not good times.
You mean write for you?
Don't tear yourself up Alexander
lost in the elementary stuff:
how do i organise a trawl pose - co-directed, for some reason it trawls one pose, i.e. it doesn't trawl... MT5
i can use a simple code section as enumeration of positions for a trawl with HEDGE market positions - thank you.
the issue is solved! Congrats once again to Vladimir Karputov!!!
with his trawl!
https://www.mql5.com/ru/code/17263
the key trick is to look at the index in the loop and modify it with the ticket option!!!
A simple task: you need to bump all elements from ArrayJ which are the same index and value as elements of ArrayI:
The key string is highlighted. Result:
Expected:
ArrayJ is dynamic, there seems to be something wrong with it... But I don't need a static one either.
Broke my mind. WHAT'S UP? Or is this the equivalent of the old song:
https://www.mql5.com/ru/forum/1111/page3141#comment_27152680
и
https://www.mql5.com/ru/forum/1111/page3142#comment_27371998
about named constants?
The key string is highlighted. Result:
Expected:
ArrayJ is dynamic, there seems to be something wrong with it... But I don't need a static one either.
1. ArrayResize would be better moved out of the loop.
2. ArrayRemove doesn't make an array element "empty", it "shifts" subsequent elements into its place. Hence the matching of elements in subsequent indexes is broken.
1. ArrayResize should be moved out of the loop
2. ArrayRemove does not make an array element "empty", but "shifts" subsequent elements in its place. Hence the matching of elements in subsequent indexes is broken.
There's no question about 2, I've just put the intervals there to make it clearer. Besides, in Help it says about a static array:"If the function is used for an array of a fixed size, the array size itself doesn't change: the remaining "tail" is physically copied to the startposition ." The example in the Help also uses a fixed size array, and I have a dynamic one.
Re 1. We can't put it outside a loop, since in a real task we don't know beforehand either the size of ArrayJ or ArrayI, much less the size of CommonArray, since they all don't coincide.
I also have an example where element dumping doesn't break halfway, as in this example:
The result is good:
But you need that variant to work. The hitch apparently happens if there are elements with the same value (see previous post) in the tail on the right - which is similar to the problem I was referring to above.
There are no questions about 2, I put the intervals for clarity. In addition, in Help it says about static array:"If the function is used for an array of fixed size, the size of the array itself does not change: it physically copies the remaining "tail" to the startposition ." The example in the Help also uses a fixed size array, and I have a dynamic one.
Regarding 1. We can't put it outside a loop, since in a real task we don't know beforehand either the size of ArrayJ or ArrayI, much less the size of CommonArray, since they all don't coincide.
I also have an example where element shuffling isn't interrupted halfway through, as in the above example:
The result is good:
But I need that variant to work. The hitch apparently happens if there are elements with the same value in the tail on the right (see previous post) - which is similar to the problem I referred to above.
1. You can and should take it out of loop, the way I've shown. Unless ArrayI size changes over the loop.
2. Then something like this
The key string is highlighted. Result:
Expected:
ArrayJ is dynamic, there seems to be something wrong with it... But I don't need a static one either.
Broke my mind. WHAT'S UP? Or is this the equivalent of the old song:
https://www.mql5.com/ru/forum/1111/page3141#comment_27152680
и
https://www.mql5.com/ru/forum/1111/page3142#comment_27371998
about named constants?
You have an extra loop.
Here is the correct variant:
Don't tear yourself up, Alexander.
Why Alexander? I am Andrei.
" Don't tear yourself up" - clarify.
You have an extra cycle.
This is the right option:
About the extra loop... It may be inappropriate here but it is necessary in a large code, so it was moved here. I don't have resources to check the correctness of the algorithm at present, but formally it works as intended.
JRandomTrader, the result was surprising: all zeros. I will double-check later.Thank you all.