I have made further investigation and something is going completely wrong frown
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

Attached Files logfile.jpg