With the Dow Jones Industrial Average hitting all-time highs and flirting with the 17,000 level, investors are getting nervous that the best gains in the stock market are behind them. But for the patient, long-term investor, there are still bargains in today's market. Here are three stocks that exhibit price-to-earnings ratios below both their five-year averages and the S&P 500's P/E, indicating huge upside potential for their share prices.

Allstate (NYSE:ALL), one of the largest publicly traded property and casualty insurers in the U.S., offers auto and homeowners policies, as well as life insurance and annuities. The company's extensive product offerings allow Allstate to build a comprehensive portfolio of products with customers, an advantage over many of its auto-centric competitors. Bundling of insurance products can also improve customer retention. To combat catastrophe losses, which are a main driver of Allstate's earnings volatility, the insurer is cutting its exposure to riskier geographic markets by raising premiums and reducing the number of in-force policies.

During the past three years, Allstate's revenue has averaged annual growth of less than 3%, yet earnings have averaged 35%. Allstate's recent P/E ratio has been around 12.7, while its five-year average P/E is just over 15. But its forward-looking P/E is 10. The company also pays a 1.9% dividend yield.

Coach's (NYSE:TPR) "affordable luxury" products allow the company to capture a piece of luxury spending while maintaining a broader consumer base than the higher-end brands. So far, Coach has managed this accessibility without degrading its brand image. And as global demand for luxury goods increases, the company's loyal customers enable profitable expansion into new markets, most notably Asia. Last quarter, Coach posted a 14% rise in international sales, with revenues in China increasing 25%. And we haven't even started talking about its incredible dividend. Coach's dividend yield recently hit 3.3%, which it's increased 350% during the past five years. Better yet, the payout ratio for the dividend is 41%, which still leaves room for further growth.

During the past three years, Coach's revenue has averaged annual growth of 6%, while earnings have averaged nearly 5%. Coach's current P/E ratio has been around 12, while its five-year average P/E is nearly 18. By comparison, the industry average P/E is about 22. 

IBM (NYSE:IBM) continues its business transformation by investing in higher-growth areas like analytics, cloud computing, big data, social, and mobile, and divesting assets like PCs and printers. With IBM's transformation to a changing technological landscape, and cost-cutting efforts, it has significantly increased profitability over time, with net income increasing to $16.5 billion in 2013 from $10.4 billion in 2007. IBM's continued business transformation to higher-profit sources and its strong cost-control efforts will likely further improve profitability levels.

Over the past three years, IBM's revenue has actually declined about 1%, but its earnings have averaged nearly 7% annually. At its current prices, I believe the market has yet to reward IBM for this profitability improvement. The company's recent P/E ratio has been about 12.6, while its five-year average P/E is 13.2. But its forward-looking P/E, based on next year's earnings, is 9. The company also offers a 2.4% dividend yield.

Foolish bottom line
Even with the Dow traversing the fast lane, there still exist good buys in today's market. Consider these three stocks for your portfolio.