The Dow Jones Industrial Average (^DJI -0.98%) was hovering just eight points under breakeven at 1 p.m. EDT Friday after suffering a triple-digit loss on Thursday.

A ray of sunshine on the Dow this morning was Home Depot (HD -0.31%), which was up 1.1%.

But, lest we forget, just yesterday Home Depot led the Dow lower.

For investors in the home-retail giant, the past 48 hours of whipsaw trading represents a perfect microcosm for the stock's behavior over the last 12 months. Let's step back from the day-to-day movements for a moment, take the long view, and ask ourselves, "To buy, or not to buy?"

The roller coaster
Home Depot is a big-box hardware store that sells refrigerators, lawn care equipment, building supplies, and general wares for home improvement. It's no surprise that the company's fortunes took a hit during the real-estate crisis. 

From those depths, though, the company rebounded strongly. Investors lucky enough to buy when others were fearful have thus far been handsomely rewarded, as the stock is up 215% over the past five years.

However, that trend from the lower left to the upper right has largely ended over the past 12 months. Take a look at the price chart over that time period (Warning: beware of whiplash as you track the price):

HD Chart

HD data by YCharts.

Why is it that Home Depot has been both up over 6% and down over 6% from one year ago today? More importantly, where is it going next?

Some big-picture considerations
Home Depot's stock price will always have some correlation to the overall market sentiment toward the housing sector. That's just the reality for a giant corporation with such a large presence in a specific industry. 

The stock fell as rates rose last year and investors saw the refinance boom come screeching to a halt. 

Then sentiment changed through the end of the fall and into the early winter. We were all writing about how the housing market was finally gaining some momentum and turning a corner. Some of us, ahem, even thought it might be the last chance to buy.

Then came the polar vortex and an abnormally cold winter, and the opinion du jour is now that the housing market is once again fragile and on the ropes.

That was the story until today's housing starts data showed a strong rebound in April. And so the whipsawing continues.

The zigs and zags in Home Depot's value are likely just a reflection of these broadly held, and admittedly short-term, views on the housing market. 

Forget the zigs and the zags, where's this stock going in five years?
It may take five years or longer, but the U.S. housing market will, with certainty, find stability. People need somewhere to live. It's that simple.

To put Home Depot into context, we'll compare it against top rival Lowe's (LOW -0.14%).

Over the past five years, quarterly revenue at Lowe's and Home Depot have tracked very closely. 

HD Revenue (Quarterly) Chart

HD Revenue (Quarterly) data by YCharts.

However, looking at the numbers on a percentage basis indicates Home Depot may have found a slight edge since the first quarter of 2013. Sales at these companies' stores decline or rise on a seasonal basis every year. Since the first quarter of 2013, Lowe's falls have been deeper than its rival in the off seasons and have not reached Home Depot's peaks for the spring and summer highs.

You can clearly see this effect by comparing the change in the companies' annual revenue totals. Over the past five years, Home Depot sales are up 19%, versus just 13% at Lowe's.

For mature companies such as Home Depot and Lowe's, it's not enough to just make a ton of sales. Those sales have to translate into profits. 

Once again, Home Depot sets itself apart from Lowe's in this metric. It doesn't matter if it's a high season or low, Home Depot has outperformed quarter after quarter after quarter.

HD Profit Margin (Quarterly) Chart

HD Profit Margin (Quarterly) data by YCharts.

What's even more impressive is how that margin is widening through time. Home Depot today squeezes out more profit per dollar of revenue than ever before compared to Lowe's. 

Let's talk value
After this cursory analysis of the earning power driving Home Depot and Lowe's, it seems clear that Home Depot is the better profit machine for investors interested in exposure to the home improvement industry. It even has a better dividend yield: 2.4% versus 1.6%.

But does its price today represent a value worth buying?

Home Depot currently trades at a price-to-earnings ratio of 20.5 times, per data from Yahoo! Finance. Lowe's trades at 21 times earnings. 

This all bears repeating: Home Depot has better sales, better profits, and a better dividend than Lowe's. And Home Depot is cheaper.

But this is just a snapshot in time. We still need to determine how Home Depot is priced relative to its historical value. 

Looking at the two companies' P/E ratios over the past 11 years, it seems Home Depot is overvalued, even as the P/E ratio has declined over the past six to eight months.

HD PE Ratio (TTM) Chart

HD P/E Ratio (TTM) data by YCharts.

The last time Home Depot traded at these levels was in mid-2010, and before that it was at the onset of the real-estate bubble in 2004. 

So despite Home Depot's strong performance, particularly relative to Lowe's, value investors have probably missed the opportunity to buy the retailer at an attractive valuation -- at least for now.

Even though I'm not buying today, I'll keep my eye on this stock. As we established at the beginning of the article, Home Depot shares have been on a roller-coaster ride the past 12 months. There may be an oppportunity to buy soon at a valuation that can get you excited.

For more business and investing analysis, Like Jay on Facebook by clicking here!