NEW YORK (Reuters) - The S&P 500 and the Nasdaq closed higher in a broad-based rally on Thursday as investors looked to the G20 summit in Osaka, Japan this weekend for progress in the long-running U.S.-China trade dispute, which has whipsawed markets for months.

The benchmark S&P 500 snapped its four-day losing streak, closing within 1% of its all-time high, reached a week ago.

The Dow closed slightly lower, dragged down by Boeing Co BA.N.

Optimism fueled by a China Morning Post report that the world’s two largest economies have agreed to a tentative trade war truce was dampened by a Wall Street Journal article saying that Chinese President Xi Jinping will present President Donald Trump with a set of conditions to be met by the United States before reaching any settlement.

Expectations of a deal were muddied further when White House economic adviser Larry Kudlow said the United States may move ahead with further tariffs on Chinese goods after the two leaders meet this weekend at the Group of 20 summit in Japan. Trump and Xi are expected to discuss a way forward regarding tariffs and other issues when they meet.

“Today’s trading is a G20 pregame,” said Matt Forester, chief investment officer of BNY Mellon’s Lockwood Advisors in New York. “Given the tone of today’s markets, people believe there will be some diminishment of trade tensions coming out of the meeting.”

“No pair of geopolitical rivals in history have had more connection to each other’s economies,” Forester added. “There’s a lot of pressure to get this right.”

FILE PHOTO: Traders work on the floor at the New York Stock Exchange (NYSE) in New York, U.S., June 5, 2019. REUTERS/Brendan McDermid/File Photo

The Dow Jones Industrial Average .DJI fell 10.24 points, or 0.04%, to 26,526.58, the S&P 500 .SPX gained 11.14 points, or 0.38%, to 2,924.92 and the Nasdaq Composite .IXIC added 57.79 points, or 0.73%, to close at 7,967.76.

Of the 11 major sectors in the S&P 500, all but energy stocks .SPNY ended the session higher.

Chipmakers, whose revenue exposure to China makes them vulnerable to tariffs, ended the session higher. The Philadelphia Semiconductor index .SOX rose 1.5%.

“Chipmakers are a proxy for trade optimism,” said Chuck Carlson, chief executive officer at Horizon Investment Services in Hammond, Indiana. “They have become the trade du jour for traders betting for or against a trade deal” between the United States and China.

Ford Motor Co F.N advanced 2.9% after the automaker announced it would cut 12,000 jobs in its troubled Ford Europe segment.

Boeing Co BA.N dropped 2.9% following a Reuters report on Wednesday that the U.S. Federal Aviation Administration identified a new safety risk in the planemaker's grounded 737 MAX aircraft.

Conagra Brands CAG.N reported quarterly earnings that missed analyst estimates because of waning demand and manufacturing challenges. Its shares fell 12.1%.

Higher drug prices and an increase in prescription volume helped Walgreens Boots Alliance Inc WBA.O beat quarterly earnings expectations, sending its stock up 4.1%.

Advancing issues outnumbered declining ones on the NYSE by a 2.50-to-1 ratio; on Nasdaq, a 2.92-to-1 ratio favored advancers.

The S&P 500 posted 6 new 52-week highs and 1 new low; the Nasdaq Composite recorded 36 new highs and 62 new lows.

Volume on U.S. exchanges was 6.14 billion shares, compared to the 6.98 billion average for the full session over the last 20 trading days.