Hi,
A break stop corrects the stop reduction to be equal to the order starting price, after a particular level of profit was reached. The break even stop is independent from your first stop loss and trailing stop.
The structure that you should use is something like this.
Not looked at your code but either you are putting stops along with your order (lots of brokers don't allow that).
You need to set order and the change the order for the stops.