On cars made in the 1980s and beyond; new parts called camshaft position sensors and crankshaft position sensors began to appear. These parts will cause exactly the symptoms you describe when they begin to fail. The 1994 Ranger 4.0 has a crank sensor, but does not have a cam sensor. I would definitely replace that part.
Another part that is only used on late model cars is the coolant temperature sensor for the engine control computer. This is a different part from the coolant temperature sensor for the dashboard temperature gauge. The temperature sensor for the computer can shut the engine down and make starting hard if it fails. On this motor; the coolant temperature sensor for the computer has a large plastic plug on it; while the sensor for the temperature gauge only has a metal post connector.
If the problem continues; I would replace the plug wires, plugs and ignition module.
And, of course; the mass airflow sensor, idle air control valve, and throttle body should all be cleaned; using only mass airflow sensor cleaner on the very vulnerable mass airflow sensor.
www.rockauto.com sells 3 different brands of crank position sensors for the 1994 4.0 Ranger for prices between $20.79 and $23.79. Listed in their online catalog, under Ford/1994/Ranger/4.0/ignition/Crankshaf
t Position Sensor.