There's nothing more enticing than the thought of hopping into a time machine with the knowledge I have now and taking advantage of what I know will happen in the future. Imagine how rich I could become with that kind of information!

What would I do if that really happened? If I could head back to the late 1990s, I'd put all my retirement contributions into Amazon, Microsoft, Berkshire Hathaway, and Apple, and close my eyes until now, when I'd likely be sitting in my beachfront Hawaiian home, sipping piña coladas while counting my millions.

But alas, not even Elon Musk has created such a reality-defying device just yet. Is there anything I can do other than lament what I coulda, shoulda, and woulda done if only I had had that knowledge?

Of course! Hindsight is 20/20, and while I can't go back and change my actions, I certainly can learn from them. So, with almost 30 years of investing success (thank goodness!) behind me, I'd like to share the top three things I wish I had known when I started to build my retirement savings.

Person holding many piggy banks.

Image source: Getty Images.

1. The Roth IRA is a golden temple of wealth

My investing-for-retirement journey began in the 1990s, right before Congress created the Roth IRA through the Taxpayer Relief Act of 1997. This breakthrough retirement account allows individuals to contribute after-tax dollars to a self-directed investment account, watch that money grow throughout their working years, and then withdraw all funds tax-free in retirement.

Let's say I started contributing $5,000 annually in 1998 and put the same amount of money each year into an S&P 500 index fund housed in a Roth IRA. During the period from 1998 through 2022, the S&P 500 earned an average annual return of around 8%. Therefore, after 25 years, I would have had just over $400,000 in my Roth IRA from my investment of $125,000 -- all available to withdraw tax-free in retirement. That's a big, fat golden goose of a retirement account.

S&P 500 chart for 25 years.

Chart source: Investor.gov.

Unfortunately for me, I needed the tax breaks, so I opted for putting my retirement money in a traditional or SEP IRA. Now, when I start making withdrawals, I'll face a rather unpleasant tax hit that will take a nice juicy bite out of my retirement income.

2. To grow your retirement funds, it's necessary to hold investments through good times and bad

When you invest in a company -- especially one in its early stages -- you're not going to see a straight line to success. But to accumulate wealth, it's important to hold a company through good times and bad, even when the desire to sell is more compelling than it is to hold through the misery. I think all investors have a tale of woe about selling something they shouldn't have, and I'm no different.

Back in 2012, I read about this up-and-coming electric-car company called Tesla (TSLA 12.06%), run by an odd genius named Elon Musk. It had all the things I look for in a speculative growth company -- great visionary leadership, not much competition, incredible potential in a breakthrough industry -- and I made a $5,000 bet. And then I encountered the naysayers.

First, a financial advisor friend informed me that the risk was too great. By that point, I had made a cool $25,000 on the stock, and my friend was concerned that not only was I putting my initial investment at risk but also my earnings, since Tesla was struggling with its growth and valuation. He made me nervous, and I sold half my position. My first dumb move.

Several years later, as I was getting closer to retirement, another financial advisor told me I needed to reshape my portfolio to a more-conservative allocation. Tesla was hitting some potholes, and I was getting those stomach butterflies again.

Instead of standing by my vision, I let this person convince me to lock in the rest of my profits and put them in something less risky since I wasn't getting any younger. Not bad advice in theory, but horrible advice in reality. If I hadn't sold a single share of that investment, my $5,000 would today be worth $397,000, as Tesla is up over 7,800% since my original buy.

Lesson learned: All companies struggle on their paths to success. Trust your vision and stand by your beliefs, even when others are trying to sway you in a different direction. To accumulate great wealth, you must hold for the long term.

3. When fear is the greatest, it's the greatest time to buy

For lesson No. 3, I could easily just say read everything billionaire investor Warren Buffett ever wrote and follow his teachings. But I think one of the most important pieces of his advice I wish I had known and followed is, "Be fearful when others are greedy, and greedy when others are fearful." This translates into "It's a great time to load up on stocks (be greedy) when everyone else is selling (out of fear)."

This is logical: When everyone's selling, prices for stocks will be dropping substantially and bargain-basement opportunities will appear. And that's when you can find value in the stock market. For instance, if I had invested $10,000 in the S&P 500 in 2008 during the global financial crisis, it would now be worth around $40,800, as the index has averaged an annual return of close to 10% since then.

However, this is easier said than done. When your portfolio is dropping by thousands of dollars every day, it's hard to muster up the courage to put more money into the market. And yet, that's how retirement wealth is created, because over the long term, the stock market has proved to be a wealth-generating machine for those who hold through good times and bad.

Lucky for me, I'm a quick learner and was able to build a hearty retirement portfolio, even though I started without knowing what I was doing and made some embarrassing mistakes along the way. A time machine would be a great purchase, and I wouldn't be surprised to see one created by Elon Musk and selling on Amazon for free Prime delivery one day.

But until then, these three lessons can help you build a successful retirement portfolio without falling into the traps that snared me.