It's been a rough few months for gold bugs. Prices are down more than 10% in the last five months, dropping at the same time that the rest of the broad market has been rallying higher.

And things have been even worse for gold mining stocks. The popular VanEck Vectors Gold Miners ETF (GDX) is down about 23% year-to-date, hovering near multi-year lows.

It's not surprising that mining stocks are getting hit harder than the metal itself in 2018.

After all, gold mining stocks are effectively a leveraged bet on gold prices - as the value of gold moves further above a miner's cost of production, profitability scales up dramatically. And the same thing happens in reverse.

For example, all-in-sustaining costs were approximately $949 industry-wide in the final quarter of last year. With gold at $1,200, a $125 drop in gold prices represents just under an 11% loss for spot traders, but almost a 50% drop in margins for gold miners.

That's the bad news surrounding this year's gold rout.

But there's some good news, too.

From a technical standpoint, gold miners look like they're finally carving out a bottom this fall. That could bring on a strong buying opportunity for metals prices in the sessions ahead. To figure out how to trade it, we're turning to the chart for a technical look at GDX, the gold miner ETF.

At a glance, it's not hard to see that GDX has had a rough run in 2018 - or that the selling started accelerating this summer.

But it's a little too early to throw in the towel on mining stocks. That's because GDX is currently forming a pretty textbook example of an inverse head-and-shoulders pattern, a bullish reversal setup that points to higher levels ahead. Don't let the silly name fool you, a study by the Federal Reserve of New York found that the results of 10,000 computer-simulated head-and-shoulders trades resulted in "profits [that] would have been both statistically and economically significant."

This setup's upside potential is being confirmed by GDX's momentum, measured by 14-day RSI up at the top of the chart. This ETF's momentum gauge has been making higher lows over the course of the reversal setup, moving from bear territory below 30 back up into its "normal" range.

The buy signal for miners comes on a breakout above GDX's neckline. Right now, that's up at the $19 level. The bottom line is if GDX can muster the strength to catch a bid above $19 in October, we've got a brand new buy signal in gold miners.

What Are "Closed-End" Mutual Funds and How Do They Fit into Savvy Investors' Portfolios? Click here to register for a free online video in which TheStreet's retirement expert Robert Powell and an all-star panel run down all you need to know. 

This article is commentary by an independent contributor. At the time of publication, the author held no positions in the stocks mentioned.

More from Investing

Facebook's Search Test Is a Reminder of its Untapped Revenue Potential

Facebook's Search Test Is a Reminder of its Untapped Revenue Potential

It Was a Confusing and Chaotic Day

It Was a Confusing and Chaotic Day

Chart of the Day: McDonald's Management Maneuvers Amid Taxes, Tariffs

Chart of the Day: McDonald's Management Maneuvers Amid Taxes, Tariffs

Market Madness: This Market Is for Stock Pickers

Market Madness: This Market Is for Stock Pickers

Jim Cramer: The Operative Term for This Tape Is Treacherous

Jim Cramer: The Operative Term for This Tape Is Treacherous