On my old layout, I used two different insulated tracks to raise and lower the gates. I put one track a bit before the crossing and connected the yellow wire to that insulated track. When the engine reached this track, the gates would lower. Then, a little more than a normal FULL train length past the crossing, I put another insulated track but with the other outside rail insulated so as to serve as the 2nd switch. I connected the white wire to it which, once the engine reached it, would raise the gates.
Note, this only worked properly with trains going in one direction.