Lately it seems that whenever a technology startup is bought for billions , be it Instagram , Yammer , Viber , Waze , Tumblr , or Whatsapp , financial analysts predict another bubble in the making. We’ve had the 2008 recession, the tech bubble bursting in 2000, and now Robert Shiller, author of Irrational Exuberance , is worried about the next bubble.

With the threat of investment bubbles bursting more frequently, how can you keep cool under fire and bridge the gap between perception and reality in order to invest rationally? How do you stay out of the cycle that everyone else seems to be stuck in?

One answer is found in the great financial figures of the past who lived through similar bust and boom cycles, and see how they prospered through it all.

Someone like John D. Rockefeller.

The making of a titan

Rockefeller had barely begun his career as a bookkeeper and investor in Cleveland, Ohio when the Panic of 1857 struck, a massive national financial crisis that originated in Ohio and hit Cleveland particularly hard. Just as he was finally getting the hang of things, here came the greatest market depression in history.

But even as a young man, Rockefeller had sangfroid: unflappable coolness under pressure. He kept his head while everyone else lost theirs. Instead of bemoaning this economic upheaval, he quietly saved his money and watched what others did wrong. He saw the weaknesses in the economy that many took for granted.

This intense self-discipline and objectivity allowed Rockefeller to seize advantage from obstacle after obstacle in his life, during the Civil War, and the financial panics of 1873, 1907, and 1929. As he once put it: He was inclined to see the opportunity in every disaster.

Within 20 years of the 1857 crisis, Rockefeller alone would control 90% of the oil market. His greedy competitors had perished. His nervous colleagues had sold their shares and left the business. His weak-hearted doubters had missed out.

School of adversity

Rockefeller would make much of his fortune during market fluctuations — because he could see while others could not. This insight lives on today in Warren Buffett’s famous adage to “be fearful when others are greedy and greedy when others are fearful.”

Rockefeller put those insights to use. When he was 25 years old, a group of investors offered to invest around $500,000 at his discretion if he could find the right oil wells in which to deploy the money. Grateful for the opportunity, Rockefeller set out to tour the nearby oil fields. A few days later, he shocked his backers by returning to Cleveland empty-handed, not having spent or invested a dollar of the funds. The opportunity didn’t feel right to him at the time, no matter how excited the rest of the market was — so he refunded the money and stayed away from drilling.

Like Rockefeller, we must practice this type of self-discipline with our own investments, whether its for a supposed “blue chip” IPO or our retirement fund. With assistance from our round-the-clock, say anything financial media, seemingly endless attractive opportunities abound — it is up to us to see through the madness of the markets.

Later in life, Rockefeller said, “Oh, how blessed young men are who have to struggle for a foundation and beginning in life. I shall never cease to be grateful for the three and half years of apprenticeship and the difficulties to be overcome, all along the way.”

But Rockefeller wasn’t born this way. This was learned behavior. These strategies were developed in the market — in bad markets specifically. And Rockefeller got this lesson in discipline in that crisis of 1857. In what he called “the school of adversity and stress.” Understanding that the obstacle is an opportunity is a formula Rockefeller and other icons used to graduate from this school of hard knocks, using timeless philosophical principles forged over centuries.

The obstacle is the way

Rockefeller’s life is more than just an analogy. We live in another Gilded Age. In less than a decade, we’ve experienced two major economic bubbles, entire industries are crumbling, and lives have been disrupted. What feels like unfairness abounds. Financial downturns, civil unrest, adversity. But outward appearances are deceptive. What’s on the inside is what matters.

We can learn to perceive things differently, to cut through the illusions that others believe or fear. We can stop seeing the “problems” in front of us as problems. We can learn to see things simply as they are. Unhelpful perceptions can invade our minds — that sacred place of reason, action and will — and throw off our compass.

Discipline in perception lets you clearly see the advantage and the proper course of action in every situation — without panic or fear. Rockefeller understood this and threw off the fetters of bad, destructive perceptions. He honed the ability to control and channel and understand these signals. Most people can’t access this part of themselves; they are given to impulses and instincts they have never questioned.

We can see disaster rationally. Or rather, like Rockefeller, we can see opportunity in every disaster and transform that negative situation into an education, a skill set, or a fortune. Seen properly, everything that happens — be it an economic crash or a personal tragedy—is a chance to move forward.

This is how you see the opportunity within the obstacle. It does not happen on its own. It is a process that requires self-discipline and logic. You must realize: Nothing makes us feel this way; we choose to give in to such feelings. Or, like Rockefeller, choose not to.