By Rodrigo Campos

NEW YORK (Reuters) - With S&P 500 earnings on track to rise after four consecutive quarters of contraction, U.S. stocks are clearing a major hurdle that puts the record high in sight for the benchmark U.S. stock index.

The S&P 500 hit a record high in mid August even after the long profit slump. The index has trended lower since then, and even closed below its 50-day average for most of the last six weeks. Some analysts have blamed the recent weakness on expectations that earnings would again fail to grow, as estimates showed until early this week.

But stronger-than-expected profit reports from companies such as Microsoft <MSFT.O> and Bank of America <BAC.N> have turned the tide and the blended earnings growth estimate for the third quarter sits now at 1.1 percent. This would effectively end the earnings recession.

"The magnitude of the beats we’ve had is really important," said Art Hogan, chief market strategist at Wunderlich Securities in New York.

"There’s a much larger chance that we break out of range to the upside than the downside and I think it happens before the end of the year," he said.

The end-of-year seasonality is also on the side of stock bulls.

Data from broker-dealer LPL Financial show that since 1980 the median S&P 500 gain in the last 50 trading days of the year is 3.6 percent, an advance that would see the index end the year near 2,200 and above its current record close of 2,190.15. It closed Friday at 2,141.16.

"With the earnings recession showing signs of ending this quarter, the economy is on firmer footing, which could lead to your typical end of year strength,” said LPL's senior market strategist Ryan Detrick.

The energy sector, which had been a large weight on S&P earnings, is leading the index in terms of the magnitude of upbeat surprises.

Early in the reporting season, profits for the sector are coming in 18 percent above expectations, according to Thomson Reuters I/B/E/S data, ahead of the 11 percent surprise factor in financials and an average of 7 percent for the S&P 500.

The strong beats bode well ahead of a week heavy in energy sector reports including its two largest companies, Exxon Mobil <XOM.N> and Chevron <CVX.N>, on Friday.

Some energy companies have been able to profit even amid a steep slump in oil prices, noted Roberto Friedlander, head of energy trading at Seaport Global Securities in New York.

He said in a Friday email that the magnitude of strong earnings surprises in the energy space was partly because investors had failed "to truly gauge how efficient and quickly the sector has been able to come down the cost curve and lower break-evens."

S&P 500 energy <.SPNY> is the leading sector in terms of year-to-date gains, up 15.3 percent in 2016. The only two other sectors up double digits are utilities <.SPLRCU>, up 10.8 percent, and technology <.SPLRCT>, up 11.2 percent.

The change in leadership to energy is "an important transition" and an indication that the economy is in stronger footing, said Wunderlich's Hogan.

"People are getting out of defensives and looking into growth."

(Reporting by Rodrigo Campos, additional reporting by Chuck Mikolajczak; Editing by David Gregorio)