You should select positions by tickets, not by symbol.
Selecting by symbol works fine only for netting account, where all trades are embedded into a single position.
I also strongly recommend to use CTrade classes libraries, for easier codes and proper error handling.
black_building:
if more than one tickets are opened at any time (not opened at the same time), MQL5 wasn't able to close all of the tickets (see enclosed figure).
Enclosed:
- Call to close long and short
- Code of closing functions
- Figure show not all are closing
Improperly formatted code edited by moderator. Please ALWAYS use the CODE button (Alt-S) when inserting code.
I was using selected by ticket but I ran to issue of I can only close one ticket. Program ignores other ticket (return ticket not found). I will modify my code to use Trade class. Does the existing "return ticket not found" issue has been resolved? If it does. Please shoot me the link.
Thanks
Have you tried counting loop in reverse?
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
if more than one tickets are opened at any time (not opened at the same time), MQL5 wasn't able to close all of the tickets (see enclosed figure).
Enclosed: