Ok, I built the 4 diode rectifed 2 transistor detector as below with a 470R resistor and led. Wired to track 15VAC DCC and 12VDC. This worked. LED lit when finger placed across track. Worked when loco placed on track, even when stationary. Exactly as it should.
https://www.electro-tech-online.com/attachments/working-jpg.36249/
On breadboard next to the detector circuit are two signalling circuits. Both linked so when one block is red the other is yellow, orbth are green.
These signalling circuits had normal push to make swtches and bot worked correctly. Each led has a 390R resistor.
I replaced the led on the detector circuit with the optoisolator (pins 1 to 2, anode to cathode) and connected the detect from the signal circuit to pin 4 (collector), then connected pin 3 (emitter) to ground.
Powered up. Green signals on. No loco on track. All good.
Put loco on track, red signal on one block lit, yellow on other block lit. Green leds did not go out. That's the problem. They should have both gone out when loco detected.