Image Source: The Motley Fool.

Whether you're a novice or veteran stock investor, one of the best ways to up your game is to take the advice of the best investors in the world. Fortunately, Warren Buffett and Peter Lynch, two of the greatest investors of all time, have offered us many nuggets of investment wisdom over the years.

Investing tips from the Oracle of Omaha

Considered by many to be the best buy-and-hold investor of all time, Warren Buffett, through his company, Berkshire Hathaway (NYSE:BRK.A) (NYSE:BRK.B), has produced average annual total returns of 20.8% since 1964 -- a staggering 1,598,284% return for those investors fortunate enough to get in on the ground floor. Buffett is famous for being generous with his knowledge, and his lessons on investing can be found all across the Web.

Here are a few of my favorites.

Never lose money
Admittedly, this is a rule that Warren Buffett himself breaks from time to time. In fact, Buffett will freely admit that he's made several bad investments over the years. Nobody is right 100% of the time, and that's especially true when it comes to stock investing.

However, that's not the point of what Buffett is saying here. Instead, Buffett means that protecting your principal investment should be a higher priority than seeking huge profits. By finding businesses with a margin of safety and identifiable competitive advantages, you can limit your potential losses, even in market crashes.

Cash is a bad investment, but it's a good thing to have
Berkshire Hathaway always keeps a substantial amount of cash on its balance sheet -- enough to cover any possible short-term expenses and some reserves -- in case a good investment opportunity presents itself. However, Buffett has pointed out that cash is a terrible investment all by itself. Savings accounts and CDs pay next to nothing in interest, and you'll actually lose purchasing power over time, thanks to inflation.

Most people shouldn't buy stocks
If you have the time and discipline to properly research stocks, then go for it. For the rest of the population, the best bet is to invest in a low-cost S&P 500 index fund, according to Buffett. The S&P has historically produced average annual returns in excess of 9%, and stock pickers who don't spend the proper amount of time are unlikely to beat that on a sustainable basis.The point here isn't to discourage you from investing in stocks, which can be incredibly rewarding. But remember that going it alone in the stock market takes a big commitment of time and effort.

If you do buy stocks, only invest in businesses you understand
Looking at Berkshire's stock portfolio, you'll notice that there are only a few tech stocks, and those are massive, mature businesses. Buffett doesn't understand new technologies well, so he doesn't invest in them, because he doesn't understand all the risks and market forces at play. Similarly, if you don't have a thorough understanding of what a business does, then you shouldn't buy its stock, no matter how cheap it looks.

Cheap garbage is still garbage
Perhaps my favorite Buffett quote of all time is, "It's far better to buy a wonderful business at a fair price than a fair business at a wonderful price." Buffett was widely criticized for his high-dollar purchase of Precision Castparts, but he justified the deal by showing what an exceptional business the company has. By contrast, Radio Shack was trading for next to nothing at the time -- and then it went bankrupt.

Stay away from debt
Buffett hates debt -- whether it's personal debt or corporate debt held by a potential investment. He tends to invest in companies with little to no debt, and he also advises investors to stay away from borrowed money -- especially credit cards. Think about it: If you earn a 10% return on your stocks, but you're paying 18% in credit-card interest, you're actually losing money.

Peter Lynch -- A simple philosophy that works

Peter Lynch is most famous for running the Fidelity Magellan Fund and achieving an unheard-of 29% average total return from 1977 to 1990. Although Lynch spent countless hours on stock research, his investment philosophy was simple enough that anyone can understand it. Here are some nuggets of Peter Lynch's investment wisdom that you can apply to your own portfolio.

Do your research
Although Lynch's strategy is simple, he still researches potential investments with incredible thoroughness. Don't buy stocks just because a billionaire investor does so -- even one named Buffett or Lynch -- and don't buy based on just one or two attractive metrics, such as a low P/E ratio.

Invest for the long term
This is a cornerstone of both Lynch's and Buffett's investment philosophies. As Lynch once said: "Absent a lot of surprises, stocks are relatively predictable over 10-20 years. As to whether they're going to be higher or lower in two or three years, you might as well flip a coin to decide."

And as Buffett has famously said, "Our favorite holding period is forever."

Now, this doesn't mean that you can't sell stocks. In fact, there are many good reasons to sell stocks, and both of these living legends have sold stocks regularly. The point is that you should approach every investment with the intention of holding it forever.

Market timing is a waste of time
The average investor doesn't even come close to matching the market's returns. Why? Simply put, they try to time the market, but their emotions force them to sell low and buy high -- the exact opposite of what they should do. When markets crash, people panic and sell. And when everyone else is making money, they buy in at inflated prices.

In an effort to see whether market timing would even be effective if it worked, Lynch once conducted a study. If an investor had bought stocks on the lowest-priced day of each year from 1965 to 1995, they would have achieved an 11.7% annualized return. On the other hand, if an investor had bought on the most-expensive day of each year, they still would have earned an annualized 10.6% return. In other words, the difference between the best and worst possible market timing didn't even make that much of a difference, and therefore timing the market is not worth the effort or the considerable risk it involves.

Don't throw good money after bad
One of my favorite Peter Lynch quotes is "Never bet on a comeback while they're playing 'Taps.'"

Everyone makes bad investments every now and then, so it's important that you learn from your mistakes and move on. Don't make an even bigger mistake by doubling down on a losing investment that's fundamentally flawed.

The bottom line

If you're a stock investor, then few investments can beat the return you'll get on the time you spend learning. As Warren Buffett put it: "The best investment you can make is in your own abilities. Anything you can do to develop your own abilities or business is likely to be more productive."

Read articles like this one, buy some good investment books (Lynch's One Up On Wall Street is one of my all-time favorites), and have conversations with investors who have been doing it for decades. Over time, you'll develop an arsenal of knowledge that will allow you to be the best investor you can possibly be.

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.