While railroads may seem old-fashioned, they're still an integral part of the U.S. economy. In 2020, about 28% of total freight was moved by rail domestically. And with practically no new railroads being built, the existing companies have a practical monopoly over the infrastructure.

The largest publicly traded railroad company is Union Pacific (UNP 0.24%) although Berkshire Hathaway owns its primary competitor, BNSF. Since 2010 (and many other periods as well), Union Pacific has been an outstanding stock. But will it continue to deliver for investors in the future?

A long track record of outperformance

If you invested $1,000 in 2010 in Union Pacific, your shares would be worth about $6,100 now. However, their performance would have been much more remarkable if you had reinvested the dividends.

UNP Chart

UNP data by YCharts.

With dividend reinvestment, Union Pacific would have turned a $1,000 initial investment made in 2010 into more than $8,000 today. The stock demolished the market, nearly doubling the performance of the S&P 500. And even over just the last five years, Union Pacific did quite well, significantly outpacing that broad market index.

Starting Year Ending Year Union Pacific Return S&P 500 Return
2011 2015 87% 80%
2012 2016 118% 97%
2013 2017 138% 107%
2014 2018 84% 50%
2015 2019 70% 73%
2016 2020 198% 102%
2017 2021 170% 132%
2018 2022 72% 56%

Source: YCharts. Note: Returns are with dividends reinvested.

In fact, when you look at rolling five-year total returns starting in 2011, Union Pacific has outperformed the S&P 500 in every period but one -- 2015-2019 -- when it trailed the market only just slightly.

So we can see that Union Pacific stock has been a great performer. But can it continue to stomp the market in the future?

2023 may be a challenging year

Practically the only railroad headlines in the news over the past year have involved the threat of a labor strike against the industry. However, legislation passed by Congress in December blocked a strike and imposed on all parties a labor agreement that the Biden administration had previously helped them negotiate.

That deal -- which eight of the labor unions had already voted to accept, but which four of the largest had voted down -- includes a 24% wage increase over five years and an immediate $11,000 average payout for workers.

However, the bill left out any provisions for paid sick leave -- a key issue for workers -- so there is still a threat of future strikes by the railroad unions, although those would be much further down the road.

Still, 2023 may be a worse year than 2022 for the railroads.

Because they move freight, when the economy slows, rail companies' volumes and revenues decline. That's why many investors use their railroad companies' health as a bellwether for the economy. So even though Union Pacific grew its operating revenue by 18% year over year in its latest reported quarter (Q3 2022), Wall Street analysts expect just 1.6% growth for 2023.

However, profits are expected to rise. The average analyst is guiding for earnings per share of $11.83 this year, compared to the $9.99 that Union Pacific generated over its latest four quarters.

Because railroads are cyclical companies, there are certain times when it is better to buy their stocks than others. Dating back to 2000, Union Pacific's average price-to-earnings (P/E) ratio is 17.5. With the stock trading at 18.1 times earnings now, some might think it's slightly overvalued. However, declines in its P/E ratio have always brought good returns.

UNP Chart

UNP data by YCharts.

While charts can't tell the whole story, they can provide interesting historical insights, especially when considering a cyclical company. After sharp declines in its P/E ratio in 2003, 2009, 2016, and 2020, the stock produced strong returns in the next five-year period. Granted, these declines bottomed out at much lower P/E ratios.

But if you dollar-cost average your way into a position in Union Pacific stock (by purchasing a set dollar amount's worth every month over the next year), then I think you have a high chance of beating the market over the next five years. But you'll need to hold on to the stock for at least five years to give yourself the best chance of outperformance.

Union Pacific's track record is excellent over long time horizons. Do yourself a favor and consider adding this industrial staple to your portfolio today.