It happens here:

crossed -= sign(crossed);

If a trade takes place, crosses is immediately set to 0 for not triggering a trade again. Otherwise, its sign is subtracted, which means that its absolute value is reduced by 1. The sign is -1 or 1 dependent on whether the number is negative or positive.