Energy prices are volatile, swinging from highs to lows, often in swift and dramatic fashion. Right now, oil is on the rise, leading investors to bid up the stock prices of companies like ExxonMobil (XOM 1.35%).

Have you missed out? That depends on a lot of factors, but it might not be the best way to think about this energy leader. Here's what you need to know.

The best time to buy Exxon is the hardest time to buy it

Oil and natural gas prices, though impossible to predict, often track along with the global economy. Being cyclical isn't the only factor here, though, because supply and demand, geopolitical conflicts, and large trading groups (notably OPEC) can all influence energy prices. While not shocking, with energy prices up from their recent lows, stocks like Exxon have been rising.

Here's the thing: Oil and natural gas are vital to the world's economy. Although there is a shift toward cleaner alternatives taking place, that is likely to be a decades-long process. So energy demand is going to be robust for years. And there are likely to be more up and down cycles along the way.

It seems probable that Exxon's stock will, at some point, get much cheaper than it is right now. At that point, investors will be wondering if the dividend will end up being cut or, perhaps, even if the company can survive.

So far, Exxon has proved it has pretty impressive staying power, noting that the dividend has been increased annually for 41 consecutive years. A strong balance sheet allows this industry giant to take on debt during weak patches so it can continue to fund its business and support the dividend until energy prices recover. At which point, it reduces leverage.

XOM Debt to Equity Ratio Chart

XOM debt-to-equity ratio; data by YCharts.

So, if you want to get the best deal, you will not buy Exxon today. You will wait until the industry is in a downturn and its stock price is in the doldrums.

That, of course, means buying when Wall Street is scared, effectively taking a contrarian stance on the company. That can be very hard to do even though it is probably the best way to ensure you get an attractive entry price.

Exxon is an industry leader

Given the recent stock-price advance, Exxon isn't exactly cheap today. So you have probably missed out on at least a portion of the potential upside here. But oil prices could go even higher; there's just no way to know. Which brings us to a reason to buy Exxon in just about any market.

If you are looking for an energy stock to add to your portfolio, Exxon has proved to be a very robust industry participant. As noted, the balance sheet is one strength.

But it also has a globally diversified portfolio and an integrated business model. Being integrated means that its business spans the entire energy sector, from drilling for oil and natural gas to moving it to processing it. That helps to soften the peaks and valleys in an inherently volatile industry.

XOM Return on Capital Employed Chart

XOM return on capital employed, data by YCharts.

Notably, Exxon has a long history of being a top performer in the industry. The graph above charting return on capital employed shows that although Exxon isn't always the industry leader on this metric, it is usually near the top.

Return on capital employed basically measures how well a company invests capital on behalf of its shareholders. If you are going to buy an energy stock today, Exxon should probably be on your short list even though it isn't trading at bargain prices.

The answer is both yes and no

If you are hoping to buy Exxon while it is cheaply priced, then you have probably missed the boat here. Oil prices have begun to move higher, and so has Exxon's stock price. You should probably wait until oil prices fall, hold your nose, and buy when everyone else is selling. The cyclical industry has proved time and again that oil prices, and the stock prices of those that produce it, eventually recover.

But if you are just looking to add energy exposure to your portfolio for diversification, then Exxon should be among your top options. Just go in knowing that you aren't getting in on the cheap -- but that's likely to be the case with any energy company you look at today.