outsider:
I would use 2 break beam sensors
I have found that a Light Dependent Resistor (LDR) placed between the sleepers is a cheap, simple and effective way to identify the existence of a train. Judicious use of timing can deal with gaps between wagons.
...R