Bro its very simple....
Firstly, For pulling a train against a gradient u need extra power for which bankers are attached.
If you want to witness come to Pune - Mumbai or Mumbai - BSL NK route... You will actually see what a gradient it is...
Secondly, though WAP5 has a higher HP output but it doesnot matter... For Ghats u need high tractive...
more... efforts... WAP5 is light in weight, have only 4 axles hence the adhesive force is less... This has been taken care in WAP7 which have high Tractive effort... WAP4 has also better adhesion to tracks as it has 6 axles...
There have been cases where while hauling Mumbai Rajdhani with 21 coaches at a speed of 130kmph, WAP5 had wheel slip... Immidiately its power was switched to WAP7 which has a higher tractive effort, a better adhesion and also higher HP output....
Having said that, WAP5 is a king where load is 17-18 coaches on flats plains and is not suited for steep gradients and higher loads...