The knock sensor monitors the engine for detonation. It is like a microphone that vibrated at a certain frequency sends out AC voltage. It is set at the frequency the whole engine vibrates at when the fuel doesn't burn right. Every once in a while they will go bad, sending out the AC voltage if the engine is running fine or not. When ever the computer gets a signal from the knock sensor, it pulls the timing retarded in order to bring it back under control. If the knock sensor is always putting out the AC signal, the computer will drive the timing to a point that the car won't run. It's a long shot, but since you have replaced a lot of things it may have been over looked.