When it comes to the stock market, I am an eternal optimist; perhaps even a "perma-bull."

That bullish perspective has cost me money recently. I've been buying when I should have been selling -- though hopefully my decision to stay invested will be justified in time.

Now is a great time to be buying stocks
Yet my glass remains half-full. In fact, my glass is almost full. That's because I can't help but think that now will turn out to have been a great time to be buying stocks.

There are still stocks to avoid -- because there's still plenty of overpriced trash on the market.

But there are also bargains -- high-quality companies whose stock prices have been unreasonably depressed in this market, prices that I think will turn out to be very attractive in the long term. Take a look at these companies, for example.

                                                Recent share price              Forward P/E

NETGEAR (Nasdaq: NTGR)                        $20                        9

Dell (Nasdaq: DELL)                               $20                        10

Oracle (Nasdaq: ORCL)                          $19                        14

BMC Software (NYSE: BMC)                   $31                        14

Google (Nasdaq: GOOG)                         $435                      19

Source: Yahoo! Finance.

I have no idea how well the share prices of these and other companies will perform tomorrow, the next day, next week, or next month. I'm very happy to let the day traders play that speculative game. But over the next three, five, or 10 years, given their strong brands and potential in the tech space, these companies should be strong performers.

In any market, investing with a long-term perspective is the key. But when the market is volatile or bearish, that long-term perspective is even more crucial.

A case study
Davis Funds, a $100 billion, New York-based fund company, hit the headlines late last year when it shelled out $1.2 billion for a 2.5% stake in investment bank Merrill Lynch (NYSE: MER) at $48 a share.

In an interview with the Australian Financial Review, Christopher Davis argued that "You want to invest in times of pessimism. Not because you like pessimism, but because you like the prices it produces."

Late last year, investing $1.2 billion in the investment banking sector took guts. The futures of many banks were then in doubt as the extent of subprime losses became clear. That story hasn't yet materially changed.

Yet, in that uncertain environment, Davis Funds paid $48 per share for its 2.5% stake in Merrill Lynch. Tellingly, Davis had no idea if the worst was over and no idea whether he bought at the bottom of the market.

Being approximately right
As it turns out, Davis didn't buy at the bottom of the market. The shares have since traded below $40. Yet I suspect Davis is not worried. At the time of his investment, Davis said he thought Merrill would turn out to be an attractive purchase over the next five or 10 years.

As Berkshire Hathaway (NYSE: BRK-A) (NYSE: BRK-B) Chairman Warren Buffett says, "It's better to be approximately right than to be precisely wrong." At $48 per Merrill Lynch share, on a five- to 10-year perspective, Davis is banking on being approximately right. That's because he is:

  1. Buying at a time of pessimism, and pessimistic times produce attractive prices.
  2. Taking a long-term perspective.

Fear + panic = bargains
Like Davis, Motley Fool co-founders David and Tom Gardner don't know if this is the bottom of the market. They acknowledge this has been a difficult time for most stock market investors. But they know that if folks stick to proven stock-picking formulas, remain patient, and invest with a long-term perspective, they will be rewarded.

After all, although pessimism produces the best stock prices, no one can time the bottom. That's why you should jump in and buy.

If you'd like to see what David and Tom are recommending today, including their top 10 picks for money now, click here to try Motley Fool Stock Advisor free.

Fool contributor Bruce Jackson owns Berkshire Hathaway B shares, as does The Motley Fool. Berkshire is a recommendation of both Inside Value and Stock Advisor. Dell and NETGEAR are Stock Advisor recommendations. Dell is also a Inside Value recommendation. Jump in and check out The Motley Fool's disclosure policy.