On January 20, Canadian stock markets were in a pit of despair.

The TSX Composite Index was down more than 8% on the year, and that was after falling 11% in 2015. The overall market was easily down more than 20% from highs last set in 2014. Investors were nervous about low commodity prices and their effect on the overall economy.

Investors were even more bearish on the Canadian banks. Short-sellers were aggressively circling the sector, telling investors loan loss reserves were too low, that commodity weakness would lead to a marked decline in nationwide housing prices, and that even dividends would be at risk.

National Bank of Canada (TSX:NA) was especially in the crosshairs. Investors didn’t like the company’s focus on eastern Canada, its sudden decision to raise $400 million in equity, and the disclosure that its stake in Maple Bank was essentially worthless. General weakness in the Quebec economy didn’t help either.

Shares of Canada’s sixth-largest bank sunk to 2016 lows of $35.83 on January 20–the same day the TSX Composite hit its own 2016 low. The dividend yield was more than 6% for the first time since the financial crisis of 2008-09.

But right as the future looked the bleakest, something interesting happened. Shares started rallying, making up most of the year’s loss by the end of January. After dipping a couple of times in February, it appears the worst is officially behind National Bank. Shares are now solidly positive for 2016 and are up more than 9%. Shares are up more than 22% from the lows set back in January.

That’s a terrific move in just a couple of months.

National Bank’s price movement offers a terrific lesson for investors. It might be painful to buy in when things look bleak, but it can often be very profitable.

Many investors might be thinking they’ve missed out on the company. A 20% move represents 2.5 years of capital gains, assuming we expect the stock to go up 8% a year.

But there’s still plenty of upside in this company. Here’s why.

Attractive valuation

When National Bank was trading at its 52-week low, shares were at less than nine times trailing earnings. That’s ridiculously cheap, especially for a company with the history and pedigree of National Bank.

These days, after the big move up, shares are still trading at just under 11 times trailing earnings. That’s not quite as cheap as a few months ago, but it’s still a pretty good deal for a stock that has been a consistent dividend payer for decades.

Great dividend

There are few dividends as solid as National Bank’s.

These days, the yield has slipped slightly under 5%, coming in at 4.9%. Sure, it’s not 6%, as it was a couple of months ago, but there aren’t many companies even paying 4.9% with a history of dividend growth.

Since National Bank paused dividend growth during the Great Recession, it’s been a dividend-growth machine. In 2010, the quarterly dividend was $0.31 per share. It has since been hiked 12 times to the current level of $0.54 per share. That’s a annual growth rate of nearly 12%.

Big potential

One thing separating National Bank from its larger peers is a lack of exposure to markets outside of Canada. It’s one of the reasons why investors were so bearish on the stock.

Hopefully, National Bank’s management heeds this message and uses the opportunity to really get serious about expanding outside Canada. A big acquisition stateside or in Europe could transform the company in a very good way. There’s a reason why National’s larger and more diverse peers command a higher valuation.

I’m not sure investors will have the opportunity to buy National Bank of Canada at less than nine times earnings again for a very long time. Assume that chance is gone. Instead, investors should be happy paying a fair price for a company with a reasonable valuation, a great dividend, and the potential for nice upside.

Like stocks with HUGE potential? Then don't miss this!

Exports of liquefied natural gas could be one of the best growth opportunities out there for long-term investors. And, we think we've identified the Canadian company to invest in. It's a global company with operations across nearly 20 countries and 70 locations. We like it so much, we've named it as 1 Top Stock for 2016 and Beyond. To find out why, click here now to learn how to access your FREE copy today!

NEW! This Stock Could Be Like Buying Amazon In 1997

For only the 5th time in over 14 years, Motley Fool co-founder David Gardner just issued a Buy Recommendation on this recent Canadian IPO.

Stock Advisor Canada’s Chief Investment Adviser, Iain Butler, also recommended this company back in March – and it’s already up a whopping 57%!

Enter your email address below to claim your copy of this brand new report, “Breakthrough IPO Receives Rare Endorsement.”

Fool contributor Nelson Smith has no position in any stocks mentioned.