The issue is that the STOP order at line 35 is placed the next candle, not immediately on entry, because the ONMARKET status is updated at the closing of the entry candle.
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok