With regard to the code attach below, How can i make my EA close Losing positions before the wining one?
Thank you in advance.
One way is to call the CloseAll() function twice - first time to close losers, second time close the rest... (perhaps passing a parameter to
differentiate the calls).
Another way is to store ticket number and float somewhere (e.g. arrays/structs) in this current loop (i.e. remove the OrderClose()) as
"pre-processing"... afterwhich, you can even sort the ticket numbers based on their float, and close them in that sequence.