Added close_entries_rule = "FIFO" to the strategy declaration. I forgot to add it in the first version. If you change FIFO to ANY it will change the order of closing the entries. Meaning it will close Entry 1 with Close 1, Entry 2 with Close 2, etc. As described above. Use it as you like best.
Cleaned up the script a bit.