Kudos to Action again.
I'm guessing you changed the cam sensors due to getting a code P0340? Were there any other codes? If no other codes, then you did the right thing by replacing the cam sensors. However since engine is still running bad, then why did the sensors go bad?
The 5.4L is durable but has a fatal flaw. The oil passages aren't that great, so synthetic oil changes should really be done every 3000 miles with a high quality filter. Do you hear any tapping? If so, your roller rockers need replacing. If tapping has been happening for thousands of miles, then you might need a new camshaft too.
Cam sensors, (even replaced correctly) will still throw this code and not work correctly if there is faulty/dirty cam sensor wiring issue or oil flow restrictions. These oil restrictions prevents the variable cam timing to work properly. Usually happens in very high mileage engines or engines not receiving oil changes on time. Continued driving will probably damage the engine.
The above is just my best guess. I could be totally wrong. We need more info. Could be a bad coil, spark plug, vacuum leak, etc. However, if no tapping noise and above is true, you could try cleaning the sensor wiring connections with electronic spray, check for any bad wiring. Also changing oil with full synthetic oil and a good cleaning additive might help.