Optimism about corporate earnings, bolstered by JPMorgan, lifted U.S. stocks on Friday and set the S&P 500 on the path for seven straight weeks of gains.

The S&P Midcap 400 index broke its all-time intraday record, rising 0.6 percent to 929.58. The index includes companies ranging from $750 million to $3.3 billion in size.

On balance, with supporting prices and in spite of mixed economic data, there is expectation of a strong earnings season, said Jim Awad, managing director at Zephyr Management in New York.

However, banks, which have led the S&P 500's gains so far this year, face strong technical resistance as three major indexes -- the KBW bank index <.BKX>, the S&P financial sector <.GSPF> and the Select Sector SPDR financial ETF -- approach multimonth highs reached last April.

If we don't take a break before breaking the April highs, we're going to be extended and overbought, so it will be a dangerous breakout, said John Schlitz, chief U.S. market technician at Instinet in New York.

Are we close to a breakout or resistance? I'd probably caution toward the latter, he said.

He said the S&P's closing in on its seventh week of gains is a warning sign for declines, which are historically not uncommon in the second half of January. The last time the benchmark rose eight or more weeks in a row was a nine-week run between November 2003 and January 2004.

The Dow Jones industrial average <.DJI> gained 55.70 points, or 0.47 percent, to 11,787.60. The Standard & Poor's 500 Index <.SPX> rose 8.05 points, or 0.63 percent, to 1,291.81. The Nasdaq Composite Index <.IXIC> added 15.11 points, or 0.55 percent, to 2,750.40.

JPMorgan shares added 3.3 percent to $45.93 after reporting stronger-than-expected fourth-quarter earnings. Its stock has risen 8.3 percent so far this year.

The KBW bank index <.BKX> rose 2.5 percent to 54.83, near a strong resistance area between 57 and 59.

Strength in banking stocks helped offset U.S. government data that showed December retail sales slightly weaker than expected.

In other economic news, higher gasoline prices helped push December consumer prices up at the fastest pace in a year and a half, which also weighed on consumer sentiment in early January, according to a Reuters/University of Michigan survey.

The average gasoline price of $3.09 a gallon is the highest since October 2008.

Increasing oil prices have contributed to a rise in the S&P energy index <.GSPE>, which is near an October 2008 high in another sign of an overextended market.

Dow component Intel Corp fell 0.7 percent to $21.13 a day after it posted a better-than-expected quarterly profit and forecast strong revenue for the coming quarter.

In the previous two quarters, when the technology bellwether beat Wall Street estimates, the S&P 500 ended the sessions in the opposite direction as Intel shares.

(Reporting by Rodrigo Campos; additional reporting by Alina Selyukh and Chuck Mikolajczak; Editing by Kenneth Barry)