NEW YORK (Reuters) - U.S. stocks rose in the first session of the new year and the Nasdaq closed above 7,000 for the first time on Tuesday as investors were optimistic that 2018 will bring more gains for the market.

The Nasdaq, driven by gains in Apple AAPL.O, Facebook FB.O, Amazon AMZN.O and Alphabet GOOGL.O, breached 6,000 in April of last year and closed above 5,000 in 2015 for the first time in 15 years. The technology index .SPLRCT added 1.4 percent on Tuesday, following a 37-percent surge in 2017 that made it the best-performing S&P 500 sector.

The S&P 500 also hit a record high close. Besides technology, S&P consumer discretionary, healthcare, energy and materials indexes all were up more than 1 percent on the day.

Major stock indexes closed out 2017 with their best performances since 2013. Many investors say the rally could continue this year with help from the recently approved U.S. tax overhaul that is anticipated to boost profits as well as the economy.

“We’re off to the races once again,” said Stephen Massocca, senior vice president at Wedbush Securities in San Francisco.

“I don’t expect the kind of moves we saw last year. But as long as monetary policy stays the way it is ... my view is stocks are going to have a decent year. And fiscal policy has become stimulative, as well, given the tax bill.”

The Dow Jones Industrial Average .DJI rose 104.79 points, or 0.42 percent, to 24,824.01, the S&P 500 .SPX gained 22.18 points, or 0.83 percent, to 2,695.79 and the Nasdaq Composite .IXIC added 103.51 points, or 1.5 percent, to 7,006.90.

FILE PHOTO: The trading floor is seen on the final day of trading for the year at the New York Stock Exchange (NYSE) in Manhattan, New York, U.S., December 29, 2017. REUTERS/Andrew Kelly

“Our best guess is the first quarter or half of the year can be OK as a continuation of last year,” said Paul Nolte, portfolio manager at Kingsview Asset Management in Chicago.

But, he said, “valuations are still stretched, interest rates are still rising, and those will provide headwinds to the market at some point.”

The S&P consumer discretionary index .SPLRCD was up 1.5 percent, helped by a gain in Amazon of 1.7 percent.

J.C. Penney JCP.N, Nordstrom JWN.N and Kohl's KSS.N climbed after a bullish Citigroup note on the retail sector detailed benefits from the corporate tax cuts.

Energy shares were up even though oil prices dipped. Oil hovered near mid-2015 highs amid large anti-government rallies in major exporter Iran and ongoing supply cuts led by OPEC and Russia. The S&P energy index .SPNY rose 1.8 percent.

Shares of casino operators Wynn Resorts WYNN.O and Melco Resorts & Entertainment MLCO.O were down after a report showed a lower-than-expected rise in Macau gambling revenue in December.

Abbott Labs ABT.N jumped 3 percent and hit an intraday record of $59.20 after two brokerages upgraded the company's stock to "overweight."

Shares of insurer Allstate ALL.N were down 2.7 percent following a brokerage downgrade.

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

About 6.7 billion shares changed hands on U.S. exchanges. That compares with the 6.3 billion daily average for the past 20 trading days, according to Thomson Reuters data.