I wrote these a few years ago, so please don't judge the code
If you trade with tight grid spacing, there will be fifo errors while the code is looping through tickets with the same OrderOpenTime(), simply ignore these.
Knock on wood, these have worked 100% of the time I have used them to 'close all trades'.
Many, many, many thanks to Steve and all the contributors of the original 'CountOpenTrades()' function. Without the original Fifo Ticket code i would have never been able to put these scripts together.
Cheers,
Gary
.