![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Thats not correct....
Here is why: (Has been explained multiple times)
When you have a list and you delete the record, you are looking at right now, then the next record will take the place in the list which you are looking at.
Since you are done with this line in your list, you will go to the next line, but the record from that line had been moved to the one you are now coming from... so you will miss that entry.
Clear?
EDIT:
The solution is to start at the end of the list, so your "for()-loop" must count backwards...
Dominik
Many thanks for your response - very much appreciated
Apologies....but....
I had searched many times for a clue to my problem and not found anything - so "Has been explained multiple times" was irrelevant to me.
If, as you state items get replaced then will PositionsTotal() change following each delete?
"The solution is to start at the end of the list, so your "for()-loop" must count backwards..." looks like the 'proper solution'
Just thought I was trying to be helpful having spent 'ages' trying to find why items failed to delete.
Dominik
Many thanks for your response - very much appreciated
Apologies....but....
I had searched many times for a clue to my problem and not found anything - so "Has been explained multiple times" was irrelevant to me.
If, as you state items get replaced then will PositionsTotal() change following each delete?
"The solution is to start at the end of the list, so your "for()-loop" must count backwards..." looks like the 'proper solution'
Just thought I was trying to be helpful having spent 'ages' trying to find why items failed to delete.
Thanks for you kind words
Yes my tests suggest items are sorted as you describe. I came to this conclusion searching through HISTORY
If I want to find all the positions in history for say - a MagicNumber - then I need the time the OLDEST trade was initiated to be the
This way I get all the trades now in HISTORY.
[You could of course, enter a really old date - say 1st Jan 2000 but that would probably mean HistoryPositionTotal is several thousands and means searching through each record is potentially too time consuming]