US stocks ticked higher for a fourth day in a row on Thursday, the longest streak of consecutive gains for the S&P 500 and Nasdaq Composite since March.

The rally brought the Dow Jones Industrial Average and S&P 500 to fresh three-month highs.

The gains would have been more impressive but for sharp afternoon selling of pharmaceutical group Merck, which lost 5.7 per cent to $38.83 after a state judge allowed a retrial for a man who blamed his heart attack on the company’s Vioxx pain medicine.

Online auctioneer Ebay staged a recovery, adding 7.2 per cent to $27.67. The stock had fallen as low as $22.99 on August 22 – 45 per cent down in the year to date.

Other internet stocks to gain included Amazon, which rose 4.1 per cent to $29.09, and Yahoo, up 1.8 per cent at $28.91.

Sears Holdings, the third largest retailer in the US, reported an 83 per cent rise in quarterly earnings, but investors took fright at the slowdown in sales and its shares fell 5.8 per cent to $141.29.

At the close, the S&P 500 was up 0.2 per cent, or 2.05 points, at 1,297.48. The Nasdaq Composite was up 0.4 per cent, or 8.07 points, at 2,157.61. The Dow Jones Industrial Average was flat, up 7.84 points, at 11,334.96.

Ken Tower, chief market strategist at CyberTrader, said investors had been confident about the economy ever since the surprise of the weaker-than-expected producer price data earlier in the week.

“[After] the PPI data, it was as if it flicked a switch for the bulls,” he said. “The soft landing argument is what has been moving the markets this week.”

Hewlett-Packard added 2.1 per cent to $35.15 after it beat analysts’ expectations with its fiscal third-quarter earnings, announced a $6bn share buyback, and gave bullish earnings guidance for the fourth quarter. HP is now trading at its highest level since the beginning of 2001.

Chipmaker Advanced Micro Devices added 7.2 per cent to $24.20 after it was raised from a “hold” to a “buy” rating by Citigroup. The stock has gained 20 per cent this week.

The energy sector continued to fall as crude prices slid further. BJ Services slipped 3 per cent to $35.21 and Valero Energy sank 3.2 per cent to $61.03.

Phelps Dodge fell 2.1 per cent to $90.01 and Freeport McMoran dropped 2.1 per cent to $53.58 as copper prices sank on speculation that a strike at the world’s largest copper mine in Chile might end.

Research in Motion gained 2.7 per cent to $79.81 on rumours that it would release a version of its Blackberry mobile email device with enhanced multimedia capabilities.

Enterprise software group soared 19 per cent to $33.70 following second-quarter results that came in ahead of analysts’ estimates.

Copyright The Financial Times Limited 2018. All rights reserved.

Comments have not been enabled for this article.