The problem is related to the exit from the position by take profit. When the "if" conditions are fulfilled, the "limit" take-profit target is executed,