NEW YORK (TheStreet) -- Worries that the U.S. economy may be headed toward deflation are on the rise. 

Listen to the mainstream commentators, and they will have you convinced that gold is a horrible investment during times of deflation. But this may not be case.

Japan is a modern-day example of how gold can react in times of deflation. Between 1998 and 2013, there was outright deflation in the Japanese economy. The Consumer Price Index of all items in Japan stood at 104.50 in October 1998. It bottomed at 99.20 in February 2013, according to the Federal Reserve Bank of St. Louis

If we take the mainstream's premise, deflation would have caused a significant decline in gold prices in Japan. Look at the chart below.

Image placeholder title

When Japan was facing rampant deflation, gold prices in the local currency (the yen) jumped more than 300%, from 34,061 yen per ounce to more than 146,000 yen.

If you bought Japanese stocks (Tokyo Nikkei Average), then you would have lost 14% in this same period. 

Thus, gold was a better investment than stocks during Japan's deflationary years. If there is deflation in the U.S., investors may be better off owning gold than stocks, according to what history has shown us in Japan.

TheStreet Recommends

In the short term, it will not be surprising if there's deflation in the U.S. economy. This is mainly because the dollar has been rising and energy prices have been declining. These combined phenomena can cause general prices to decline for short periods of time.

But in the long run, rampant inflation seems to be the fate of the U.S. economy.

Since the financial crisis of 2008, a significant amount of dollars have been printed out of thin air, thanks to the Federal Reserve. As it stands, there's already monetary inflation -- the amount of money in the U.S. economy has skyrocketed.

The monetary base in the U.S. economy (that is, money in the hands of the public, in bank deposits, and reserves) stood at $847 billion in August 2008. In April 2015, it stood at $4.06 trillion, according to the Federal Reserve Bank of St. Louis. This represents an increase in the money supply of more than 379% in a matter of a few years. (Read more about how inflation works here.)

Give it some time, and this will all result in price inflation.

But no matter whether there's deflation or staggering inflation, gold is setting up to reward investors.

Right now, gold is trading in a tight range and there's a significant amount of pessimism toward gold bullion -- and that's exactly when it should be the most attractive to investors.

Remember that the best investment opportunities are formed in times when investors are pessimistic and don't want to own certain assets. Gold is in a situation similar to that of general stocks in 2009. It's oversold, undervalued, feared, and unwanted. In other words, it's a contrarian investor's dream.

This article is commentary by an independent contributor. At the time of publication, the author held no positions in gold, gold mining stocks or gold-related ETFs.