U.S. stocks rose Thursday and the Dow Jones Industrial Average notched a fifth consecutive day higher after strong results from retailers lifted sentiment across the market.

Heartening reports from Macy’s, Dollar General and Dollar Tree helped counter a gloomier view of retailers last week, when results from Walmart and Target raised concerns that rising costs are eroding profits.

“After having a real challenging time with retail last week, you’re starting to see some other signs that not everybody in retail is doing poorly,” said Wayne Wicker, chief investment officer at MissionSquare Retirement. “It probably provides a little more confidence that the consumer continues to be reasonably strong.” 

The Dow industrials gained 516.91 points, or 1.6%, to 32637.19, off 11% from their January record. The S&P 500 advanced 79.11 points, or 2%, to 4057.84. The tech-heavy Nasdaq Composite climbed 305.91 points, or 2.7%, to 11740.65, helped by gains in shares of Apple, Microsoft, Amazon.com and Tesla.

Equity investors have endured a particularly volatile period lately. At the end of last week the S&P 500 fell far enough that it was on track to close at least 20% below its January peak. The benchmark then reversed course to avoid closing in bear-market territory.

Despite the advances by major indexes this week, many investors expect markets to remain unsettled for some time to come.

“I think we’re going to still go through some more volatility ahead,” said Leslie Thompson, chief investment officer at Spectrum Wealth Management.

Investors have been considering how the Federal Reserve’s plans to tighten monetary policy could weigh on economic growth and the performance of financial markets.

Fed meeting minutes released Wednesday showed that policy makers were in agreement for half-percentage point rate increases in June and July, in line with previous communication. Major stock indexes closed higher after the release. 

“To some extent, markets have been reassured that the Fed isn’t going to tighten more aggressively than what is expected,” said Luc Filip, head of investments at SYZ Private Banking.

Traders worked on the floor of the New York Stock Exchange on Tuesday.

Photo: justin lane/Shutterstock

Money managers are closely watching fresh data as they gauge the health of the economy. On Thursday a second reading of first-quarter U.S. gross domestic product came in worse than the first with a contraction at an annual rate of 1.5%.

“Economic data has come in weaker than expected lately. We do see this tightening in the economy. How severe the growth slowdown is what markets are thinking about now,” said Shaniel Ramjee,

a multiasset fund manager at Pictet Asset Management.

Initial jobless claims fell last week and hovered near historic lows, suggesting a mixed economic picture. 

Earnings reports continued to drive moves in individual stocks. Analysts have been scrutinizing results for indications that inflation has begun to weigh on profits.

“We are focusing on earnings and profitability. A lot of stable companies are reporting lower guidance,” Mr. Ramjee said. “Even the tech sector is not immune to margin pressure, especially from input costs like wages.” 

Shares of

Williams-Sonoma jumped $15.02, or 13%, to $130 after the retailer posted profits that beat analysts’ expectations. Macy’s shares climbed $3.71, or 19%, to $22.92 after the department-store chain reported robust sales growth and lifted its earnings guidance.

Dollar Tree shares advanced $29.21, or 22%, to $162.80 and Dollar General shares rose $26.79, or nearly 14%, to $222.13 after the discount retail chains beat Wall Street’s earnings expectations. It was the best one-day gain on record for both stocks, according to Dow Jones Market Data.

Nvidia shares rose $8.76, or 5.2%, to $178.51 after the chip maker posted record revenue, though its sales outlook for the current quarter came in below Wall Street’s estimates.

Shares of VMware added $3.82, or 3.2%, to $124.36 after Broadcom confirmed that it will acquire the cloud computing firm for $61 billion in cash and stock. Broadcom shares rose $19.03, or 3.6%, to $550.66.

In the bond market, the yield on the benchmark 10-year U.S. Treasury note rose to 2.756%, from 2.746% Wednesday. Yields rise as bond prices fall.

Global oil benchmark Brent crude added 3% to trade at $117.40 a barrel.

Overseas, the pan-continental Stoxx Europe 600 rose 0.8%. In Asia, major benchmarks were mixed. The Shanghai Composite Index added 0.5% while Hong Kong’s Hang Seng fell 0.3%. Japan’s Nikkei 225 also declined 0.3%. 

South Korea’s central bank raised a key policy rate to 1.75% on Thursday and signaled it would tighten policy further to keep fighting against high inflation. 

Write to Karen Langley at karen.langley@wsj.com and Anna Hirtenstein at anna.hirtenstein@wsj.com