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
Bravo! After correcting a couple of errors, you've knocked me off the pedestal even without using ArrayCopy. Checkmate. :))
for(;;)
to
Still exit via break
P.S. Just for fun, ran a direct copy across the whole array.It's probably worth changing
to
Still exit via break
Runs slower than:
If you enter this contest without any rules, you should copy the code of the "leader" (currently Kuznetsov) and modify it in accordance with the above-described system behavior.
This leads to a stable gain of about 20 msec from the initial 740 msec runtime:
By the way, I'm curious how the results will change if the original array is a series. ArraySetAsSeries(arr,true)
If we take this contest without rules, we copy the code of the "leader" (currently Kuznetsov) and modify it according to the above behavior of the system.
We get a stable gain of about 20 ms from the original 740 ms execution time:
It's worth adding. If you don't care about the sequence of array elements. Then yes, it is an excellent variant. If it's important to maintain consistency, then something else is needed.
While we're at it, here's my version:
results:
S.S. In principle, the speed limit has been reached. Next step is just micro-optimization and fiddling with the for loop:
I think Nikolai's result is a skillful use of such micro-optimizations.
There is an array containing a set of data of type 1,2,3,6,9,5,6,3,25,6,8,7,4 you need to remove e.g. values 3 and get the same array without 3 and empty spaces in the output...
I'm looking for the fastest way to clear an array of unnecessary values...
The following example comes to mind
Maybe there is a cheaper and faster way ?
Vladimir, why is this necessary?
As I understand it, it has to be done with the indicator buffer. But wouldn't it be more logical to replace empty and/or "unnecessary" values with the previous value or, for example, the arithmetic mean of the extreme values? Then it will be much faster and the array dimension will remain the same.
Vladimir, why is this necessary?
As I understand it, it has to be done with the indicator buffer. But wouldn't it be more logical to replace empty and/or "unnecessary" values with the previous value or, for example, the arithmetic mean of the extreme values? Then it will be much faster and the array dimension will remain the same.
Vladimir, why is this necessary?
As I understand it, you have to do it with indicator buffer. But wouldn't it be more logical to replace the empty and/or "unnecessary" values with the previous value or the arithmetic mean of the extreme values, for example? Then it will be much faster and the array dimension will remain the same.
When there are multiple EAs with a large number of open positions/orders in mql4, in my opinion, it is easier to keep the array with tickets and check if the order is closed by going through the array instead of trying all open positions with check for symbol and magician. So, if the order is closed, it should be "crossed out" of the array. In such cases, I used to copy the array "into itself" and reduce the array size by one. That was suggested by Vasiliy Sokolov, thanks a lot, I will know it's not the hardest option, as I never thought about speed. Why the task was to remove several equal elements is another question...
ps While I was writing this, the answer is already there. So the question is already wrong too... ))))))When there are multiple EAs with a large number of open positions/orders in mql4, in my opinion, it is easier to keep the array with tickets and check if the order is closed by going through the array instead of trying all open positions with check for symbol and magician. So, if the order is closed, it should be "crossed out" of the array. In such cases, I used to copy the array "into itself" and reduce the array size by one. That was suggested by Vasiliy Sokolov, thank you very much, I will know it's not the hardest option, as I never thought about speed. Why the task was to remove several equal elements is another question...
ps While I was writing, the answer is already there. It turns out that the question is already wrong too... ))))))I roughly figured it out then.
If we have an array of orders, the order is not important, so it is more reasonable to use the Kuznetsov's variant with filling "holes" with values from the upper part of the array, so as not to move the rest of the array elements. This is of course faster.