The all-time highs reached in the markets have made investors wary that a correction is occurring soon because too many stocks are overvalued, but divesting equities and going to cash has many risks.

Despite the fact that many stocks appear expensive, timing the market can be a fool's errand because not only do investors have to sell at the right time, they also have to decide when to enter the market again, said Ron McCoy a portfolio manager with Covestor, the online investing company, and founder of Freedom Capital Advisors in Winter Garden, Fla.

"Going to all cash can be a costly mistake," he said. "Most investors and even professionals aren't that lucky and realizing that is very important."

While investors should take a profit when the opportunity arises, all of their positions should be scrutinized.

"If investors are nervous, they can raise some cash, but should also be prepared to buy back in if they are wrong," McCoy said. "That is not easy to do mentally." 

Before investors divest their assets, they should consider the ramifications of the Trump administration passing a corporate tax break of 15%, which the markets will view favorably because it will boost profits, said Jason Spatafora, co-founder of and a Miami-based trader and investor known as @WolfofWeedST on Twitter.

"While the market is exceptionally high right now, I understand why some investors feel it's best to hedge their bets and go cash," he said. "These investors need to understand the catalyst first before rushing out the door."

Investors who time the market often miss the upside such as when the market bounced back by 13% after the presidential election, said Don Shelly, a finance professor at Cox School of Business at Southern Methodist University in Dallas. If you invested $1 in the market in 1996 and stayed invested, your investment grew to $4.82, compared to $1.60 in Treasury bills, according to Morningstar, the Chicago-based independent investment research provider.

"If you had tried to time the market and missed the 13 best months over this 20-year period, your investment would be worth $1.64," he said. "Timing the market is notoriously difficult. Nobody can do it consistently."

Sectors Which Could See Higher Moves

Industries such as biotech and energy still have room to move up, Spatafora said.

"They seem to be good sectors to diversify your portfolio given consumption needs for power and an aging Baby Boomer demographic," he said.

Investors should not exit the market since they could miss out on a period of continued above average growth, said Michael Berger, founder of Technical420, a Miami-based company that conducts research on cannabis stocks and a former Raymond James energy analyst.

"Improvements in technology have made it very easy for investors to get in and out of positions and recent investors should use volatile periods as buying opportunities," he said.

Biotech and data security companies remain good buys and some companies are undervalued. Biotech companies do not trade on earnings and instead rise or decline based on FDA approval.

"We think investors need to be selective and focus on companies with a deep pipeline of products in advanced stages of FDA testing," Berger said.

Data security is another bullish sector because of the increase in cyber criminal activity.

"One company we are favorable on is Palo Alto Networks (PANW) - Get Report and we expect to see the company continue to benefit from bullish global sector trends," he said.

Energy, health care and technology remain good sectors, although health care will be "choppy due to changing legislation," Shelly said.

"Long-term demographics favor the sector, he said. "Tech has many pricey companies, but it is the source of long-term productivity growth."