The Dow Jones Industrial Average barely reached a seventh straight record high on Friday and the S&P 500 and Nasdaq also closed at a record as gains in Kraft Heinz helped offset selling in energy stocks.

Continue Reading Below

After suffering losses for most of the session, the Dow and S&P 500 turned positive in the final minutes of a week fueled by the "Trump Rally" that has seen stocks surge since the November presidential election.

"Corporate earnings are fine, the economy's fine, the Fed's going to raise rates, and that's great for financials," said John Canally, chief economic strategist for LPL Financial.

Kraft Heinz jumped 10.74 percent after it said it would continue to pursue a $143 billion bid for Unilever , despite being rebuffed. Unilever's U.S.-listed shares surged 14.00 percent.

Eight of the 11 major S&P sectors rose, with consumer staples adding 0.66 percent, helped by Kraft Heinz as well as a 4.32-percent increase in Colgate-Palmolive and a 4.19-percent rise in Kimberly-Clark.

The S&P energy sector fell 0.53 percent as oil prices slipped.

Signs of a strengthening economy as well as anticipated tax cuts were behind the most recent optimism. With a strong fourth-quarter earnings season mostly complete, many investors say they need concrete signs of progress from Trump on his policy plans.

Uncertainty around other potential Trump policies is an additional risk, some investors say.

"People are focusing on only the good of what his campaign promises were," said Lindsey Bell, an investment strategist at CFRA Research. "What makes me nervous is that it feels like the market is ignoring what could come on immigration, trade, healthcare - the negative implications that could come from a protectionist government."

With a long weekend ahead due to the Presidents Day holiday on Monday, trading was a bit lighter than usual.

The Dow Jones Industrial Average rose a marginal 0.02 percent to end at 20,624.05, while the S&P 500 gained 0.17 percent to 2,351.16. The Nasdaq Composite added 0.41 percent to 5,838.58.

For the week, the Dow rose 1.7 percent, the S&P 500 added 1.5 percent and the Nasdaq gained 1.8 percent.

UnitedHealth sank 3.68 percent after it was sued by the U.S. Justice Department over Medicare charges.

Declining issues outnumbered advancing ones on the NYSE by a 1.15-to-1 ratio; on Nasdaq, a 1.26-to-1 ratio favored advancers.

The S&P 500 posted 46 new 52-week highs and one new low; the Nasdaq Composite recorded 141 new highs and 24 new lows.

About 6.4 billion shares changed hands on U.S. exchanges, below the daily average of 6.8 billion over the last 20 sessions.