Strong earnings from IBM and others lifted the Dow on Wednesday and compensated for worries about US-China trade relations and a government shutdown following a volatile session.
The Dow Jones Industrial Average finished up 0.7 percent at 24,575.62.
The broad-based S&P 500 advanced 0.2 percent to 2,638.70, while the tech-rich Nasdaq Composite Index added 0.1 percent at 7,025.77. 
Procter & Gamble surged 4.9 percent after lifting its full-year sales forecast following better-than-expected results, while fellow Dow member IBM jumped 8.5 percent after results topped expectations.
United Technologies, another Dow component, advanced 5.4 percent after results.
But all three stock indices slid into negative territory for a stretch in the middle of the session amid worries over trade and the shutdown.
‘We need to get these things resolved before investors feel more confident about this market,’ said Art Hogan, chief market strategist at National Holidings.
Economists have downgraded their growth estimates for 2019 and some financial analysts view an earnings recession – defined as two or more quarters of falling profits – as a rising possibility.
Among others reporting earnings, Comcast jumped 5.5 percent after reporting a 26.1 percent rise in quarterly revenues to $27.8 billion, with net subscriber additions exceeding expectations.
But Kimberly-Clark shed 2.7 percent after fourth-quarter profits fell 33.4 percent to $411 million, with higher commodity costs denting earnings.