NEW YORK (Reuters) - Wall Street gained on Monday, with all three major indexes closing near session highs as sustained optimism on the prospects for U.S.-China trade relations propelled technology shares.

Workers move a Google logo during the opening of the new Alphabet's Google Berlin office in Berlin, Germany, January 22, 2019. REUTERS/Hannibal Hanschke

The S&P 500 index and the Nasdaq both closed above their 100-day moving averages for the first time since October. Shares of Apple Inc and Microsoft Corp each rose 2.7 percent and were the top boosts to the benchmark S&P 500 index and the Nasdaq. Apple and Microsoft’s gains helped S&P 500 technology stocks gain 1.6 percent, the greatest rise among the benchmark index’s major sectors.

High expectations for Alphabet Inc’s quarterly results, announced after the bell, were likely a contributor to tech and internet stocks’ advance during market hours, said Michael O’Rourke, chief market strategist at JonesTrading in Greenwich, Connecticut.

Yet in after-hours trading, Alphabet shares fell more than 2 percent. While its fourth-quarter revenue and profit beat Wall Street’s expectations, spending grew more than expected.

FAANG earnings have been a mixed bag. Shares of Apple and Facebook Inc rose after those companies’ quarterly results, while downbeat forecasts from Netflix Inc and Amazon.com Inc dragged down those companies’ shares.

Continued optimism regarding a possible trade truce between the United States and China also boosted tech shares, said Shawn Cruz, manager of trading strategy at TD Ameritrade in Jersey City, New Jersey.

“That’s the theme that’s going to be driving markets for the next couple of months, a focus on geopolitical headlines,” he said. “There’s not any negative news developing on the trade dispute with China front. That’s giving tech a little bit of a bid today.”

Slideshow ( 2 images )

S&P 500 industrial stocks, another trade-sensitive group, posted the second-highest percentage gain among sectors, advancing 1.3 percent.

The Dow Jones Industrial Average rose 175.48 points, or 0.7 percent, to 25,239.37, the S&P 500 gained 18.34 points, or 0.68 percent, to 2,724.87 and the Nasdaq Composite added 83.67 points, or 1.15 percent, to 7,347.54.

After having dropped nearly 20 percent below its record Sept. 20 close, the S&P 500 is now less than 8 percent away from reaching that level. U.S. stocks have been lifted so far this year by the Federal Reserve’s resolve to be “patient” with further interest rate hikes in addition to signs of progress in U.S.-China trade talks.

Earnings season has also been relatively positive. About 71 percent of the S&P 500 companies that have reported so far have exceeded analysts’ estimates, according to IBES data from Refinitiv.

Analyst estimates for fourth-quarter profit growth are now at 15.4 percent. The profit growth forecast for the first quarter of 2019, however, is much lower at 0.5 percent.

Allergan Plc shares dropped 3.8 percent after the FDA approved Evolus Inc’s cheaper version of blockbuster Botox. Evolus shares jumped 11.8 percent.

Shares of Ultimate Software Group Inc surged 19.7 percent after the HR software provider announced that it had agreed to be acquired in a deal valued at about $11 billion.

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

The S&P 500 posted 13 new 52-week highs and no new lows; the Nasdaq Composite recorded 63 new highs and 15 new lows.

Volume on U.S. exchanges was 6.52 billion shares, compared to the 7.62 billion average over the last 20 trading days.