As it's an overnight transfer you won't be allowed to do an airside transfer. In any case you wouldn't be allowed to enter T4 as you don't have a boarding card for T4.
As travelling between T4 & T5 you need to use the free bus services, using the train would mean returning to T1 first.
http://www.heathrowairport.com/heath...al4toTerminal5