Due to it being intermittent when it is stationary would rule out other reasons like faulty wiring, main fuse. car alarm, etc...
If it didn't start at all or it turned off when car was running I'd be looking for something else (loose connection/wiring, fuel pump, fuel lines, AFMs, IC piping, Ignitor, etc..).
When something doesn't start it points to an inhibited Fuel, Spark, Air issue. (or a mixture of these).
As yours starts sometime it is likely your battery recovers some charge.
Quick way to tell - swap the battery with a mates, mum/dad, neighbour. Rules it in or out.
Then we can start helping further
Edit: Could try swapping the ignitor too. Make sure it's grounded. Yours could be almost farked.
IMHO