Before we ever risk a dollar in the stock market, there are some things we know ahead of time.

We know that the stock market will rise and fall, sometimes violently. Right? We know that. We also know that economic problems and political crises of various kinds will come along from time to time to temporarily make matters worse. They’re inevitable. We know that.

And hopefully we know that the key to our success will not be our financial brilliance (or most of us would immediately be disqualified), but whether we have the self-discipline to think objectively when others are acting emotionally.

If you’re a stock investor, the past 12 months, which contained two sudden (and to some, frightening) selloffs in blue-chip stock prices of more than 10%, have provided a gauge of your mental toughness. (If you’ve been anxious about your portfolio this year, your stock allocation is likely too high for your risk temperament.) Most people believe they can handle risk. This market has put that self-image to the test.

Hopefully, you’ve passed with flying colors and you’re still on board with your long-term plan. Good for you! But in case you could use a little encouragement right about now, this history lesson should provide a shot in the arm to your efforts to stay on course.

In the accompanying graph, the upward sloping line is a picture of the S&P 500 stock index from 1962 to the present. (The graph is logarithmic, meaning it shows price changes in percentage terms rather than dollar terms.) In order to give you the big picture, it’s been smoothed out to eliminate fluctuations of less than 20% (bear markets are commonly defined as selloffs of 20% or more).

On the graph, I’ve added dots indicating 12 events which, at the time, created great turmoil in U.S. and world affairs. These “crises” were primarily triggered by either political or economic factors. On each occasion, fear was rampant. The emotional atmosphere was similar to the one we experienced during the first six weeks of 2016, and much worse.

Here are three lessons that this bit of history has for us:

  1. Periods of sustained weakness are going to happen, but they are relatively rare. The bull markets run further and last longer than the bear markets. Your investing game plan should take this fact into account. The long-term investor should look at periods of weakness as temporary buying opportunities rather than sell signals.
  2. During your wealth-building years, it pays to stay invested in stocks. (I’m referring to a diversified portfolio, such as those in the S&P 500, not individual stocks.) Reflecting the strength of the U.S. economy, stocks have been — through wars and crises of many kinds — on a long, upward march for decades. Looking at the overall value of your holdings on a weekly/monthly basis is to be avoided. It fosters emotional decision-making. The decisions of successful investors are driven by the mind rather than the heart.
  3. “Crises” typically have only a temporary dampening effect (if any) on stock prices unless they directly affect the profits of corporate America. A current illustration: The past two years have seen war and significant political upheaval in the Middle East, yet has had no negative impact on corporate profits or the U.S. stock market. Only two of the events marked on the graph occurred near the beginning of a bear market, and both of them (the 1973 OPEC oil embargo and 2008 financial crisis) had significant short-term implications for the U.S. stock market.

Short-term fears can undermine your long-term confidence. But today’s news is tomorrow’s history, and it will soon pass. Having a long-term investing plan you can stick with will steady your hand, and you’ll be much less likely to go off-course when the headlines turn scary for a season.