After four straight years of declining restaurant traffic, McDonald's (MCD 0.12%) looks as if it's finally about to snap the losing streak.

The fast-food chain reported third-quarter earnings that not only saw sales and profits beat analyst expectations, but also, more importantly on many levels, revealed a higher number of guest counts.

Couple at McDonald's looking at phone

Image source: McDonald's.

A record it would rather not have

For the past four years, McDonald's hasn't been able to grow its customer base. While comparable sales have come in higher, they were predicated on higher prices and on having customers buy a more expensive mix of products. What it didn't include was more customers.

Earlier this year, McDonald's said it had lost a half billion customers over the past four years. Even as its vaunted turnaround in sales was born with the addition of all-day breakfast to its menu and discounted meal packages, customers still stayed away.

Last year the burger shop looked as if it might be on track to break its streak, having reported higher traffic numbers in the first and second quarters, but in the third, guest counts turned negative and then closed out the year down cumulatively as well.

Chart showing McDonald's comparable sales vs. guest traffic

Data source: McDonald's quarterly SEC filings. Chart by author.

A change for the better

McDonald's looked to be on track to do the same thing again. While first- and second-quarter traffic was higher, the trends were weaker than they had been in 2016 and Q2 numbers were falling off. But a funny thing happened in the third quarter this year: McDonald's reported a strong upturn in traffic, so that over the first nine months of 2017, guest counts are more than 2% higher than a year ago.

As CEO Steve Easterbrook said during the earnings conference call with analysts, "We're building a better McDonald's and winning back customers with great-tasting food, compelling value, and an enhanced experience."

That bodes well for the rest of the year, and while the numbers could turn south once more, it indicates McDonald's is finally on the right track.

Still, there are a couple of caveats.

Temper your enthusiasm

First, these numbers are reported on a global basis; we don't find out till the end of the fourth quarter how U.S. guest traffic is going. Last year, global traffic numbers were down 0.3%, but off 2.1% in the United States. The strength we're seeing now could be higher global numbers. McDonald's is a global operation, but the U.S. remains its largest and most important market.

Second, these numbers don't reflect the full impact of hurricanes Harvey and Irma, which hit in late September, just before the end of the quarter. We'll probably see a full reckoning of the effect they had at the end of the year.

Still, the burgermeister's rebound has been notable even in light of the strength its rivals have shown. Although the fast-food industry is benefiting from a general decline in dining out at casual restaurants, both Burger King and Wendy's (WEN 0.32%) have been doing noticeably better over an extended period. Now, though, McDonald's appears to be gaining on them.

Burger King owner Restaurant Brands International (QSR 0.20%), which also owns the Tim Horton's and Popeyes chains, just reported earnings, and though it has reported positive comparables in 10 out of the past 11 quarters, the latest quarter's comps were lower both against its own results from last quarter and from the performance at McDonald's performance. (They were, however, substantially higher than a year ago.)

Chart comparing comparable sales of McDonald's, Burger King, and Wendy's.

Data source: company SEC quarterly filings. Chart by author.

Wendy's will be reporting its results soon, and its past results show improving metrics as well. It's likely that its comps will be higher, too.

The chains may be benefiting at the moment from the rising tide that lifts all boats, but that would make the results at McDonald's all the more remarkable. It's had to swim hardest against the riptide trying to pull the burger chain out to sea, and it's come the furtherest along.

A lot can happen between now and the end of the year, but McDonald's may yet break this long losing streak.