It's easy to become a frustrated investor when bad news hits a stock in your portfolio. It is very natural to focus on all of the money that you are losing now, rather than the longer-term ramifications of the news.

But if you are a long-term investor, the volatility caused by each day's news can help you profit over time. Sometimes, a stock falls dramatically because of bad news that gets blown out of proportion. When that happens, savvy investors -- those who are focused on the long-term picture and not just the day's news -- can sometimes find great bargains.

Allegiant takes off
One great example played out over the past two weeks at Allegiant Travel (ALGT -4.15%), an ultra-low-cost airline. On Friday, Sept. 20, Allegiant announced that it was grounding around half of its fleet after learning that many of its evacuation slides had not been inspected often enough. This led to numerous flight delays and cancellations over the next several days.

Investors took the news badly, sending the stock down from over $103 before the news came out to around $95 on the following Monday morning. This occurred even though Allegiant was managing to reaccommodate most customers -- albeit with significant delays -- and promised to have all aircraft back in service by the end of September.

Indeed, by the middle of last week, Allegiant's flight schedules had mostly returned to normal. While Allegiant still has a number of evacuation slides being inspected, September is a low-demand period for leisure travelers, so the airline has been able to operate its full schedule with fewer planes.

Investors quickly realized that the slide inspection problems were very temporary in nature. As a result, the stock surged last week, regaining all the ground it lost, and then some. By Friday, Allegiant stock was approaching the all-time high of $109.72 it set earlier this year.

ALGT Chart

Allegiant Travel 3 Month Price Chart, data by YCharts.

The case of Allegiant shows how dramatically a stock can fall when it gets hit by bad news -- and how fast it can snap back when investors take a step back and look at the big picture. Allegiant has significant long-term growth prospects, an industry-leading cost structure, and high profit margins. Last week's dip was therefore a great buying opportunity.

Another opportunity?
Hewlett-Packard (HPQ 1.55%) is another stock that has recently sold off on bad news but could be primed for a comeback. HP stock had been on a tear for nearly a year as investors became more comfortable with the company's turnaround plan. But CEO Meg Whitman spooked investors last month by shaking up her management team and announcing that HP was unlikely to return to revenue growth in 2014.

HPQ Chart

Hewlett-Packard 1 Year Price Chart, data by YCharts.

But as I noted at the time, most analysts covering HP already expected revenue to decline in 2014. On the flip side, the company has cleaned up its balance sheet since the ill-fated Autonomy acquisition, and cash flow has been growing. This should allow HP to return more cash to shareholders going forward, in the form of higher dividends or buybacks.

Despite these positive steps, HP stock trades for just 5.5 times free cash flow. That valuation implies that HP's profitability is on the verge of collapse. Yet analysts  expect modest EPS growth next year, even though revenue may decline an additional 3%.

Next week, HP will hold its annual analyst meeting, at which it will provide detailed guidance for next year and a business update. If HP's management forecasts flat to positive earnings growth, I expect the market to reevaluate the company's prospects. This could send the stock back toward its recent highs, especially if management announces plans to return more cash to shareholders.

Foolish conclusion
As an investor, it's important to be able to see the long-term implications behind the daily flow of news. Sometimes, bad news is really bad, and the best decision is to cut your losses. But in many cases, the market overreacts to a piece of news, creating a great buying opportunity for long-term investors.

In the case of Allegiant, it took just a few days for investors to realize there had been no good reason to sell the stock. So far, HP investors have not relented following the stock's late August sell-off. Nevertheless, I expect the stock to regain some ground after management provides more perspective next week.