2003 F150 4.6 liter engine

What causes the tempurature gauge to go to hot but no steam is showing or overheating present when put on diagnostic machine no problem with tempurature and shows cylinder head overtempurature sensor but then it cools down for a few minutes and runs fine then starts with gauges showing hot again put new termostat,spark plugs ,flushed radiator flluid put new idle control sensor and fuel filter new battery cables new timing chains and new oil pump when tempurature gauges act up the truck has no power then when turned off and restart it runs fine for several miles then acts up again what do I need to replace can you fix my problem with this thank you. edward