There is a type of investment called "target-date mutual funds." The idea is that if you know you are going to retire in 20 or 30 years, the mutual fund is invested in higher growth, riskier funds at the beginning of the 20 to 30 years and gradually shifts to higher percentages of more conservative investments as the target date approaches.
The idea is that you get maximum growth for the bulk of the investment period, and as you approach retirement you lock in more and more of your earnings - they are switched to investments less vulnerable to declining value.
Not all of these funds have lived up to their promise, but the idea behind them is sound. You can do some of this yourself by reviewing investments annually, staying diversified. As time marches on, move your money out of more volative equities and into high quality bonds, treasuries, and other more stable income-type investments.