Quick and dirty, I use a lot of such solutions!

Quote:
Create stop.txt shortly before stopping the script, and delete it right after.

Hmm ... but instead of creating the stop.txt shortly before stopping the script I could also execute the for(all_trades) loop - if I only knew when the time is "shortly before stopping the script" but this is the time in question.