I have made further investigation and something is going completely wrong
![frown frown](/ubb7/images/graemlins/default_dark/frown.gif)
With the script I posted before the expected behavior should be that after a loss it should reverse the trade. As I can see in the logfile, it opens the reversed trade 1 minute before the original trade was closed and also the entry is at a different level then the stop before.
![confused confused](/ubb7/images/graemlins/default_dark/confused.gif)