Asset bubbles have been around for a very long time.

One of the first was Holland's Tulip Mania in the 17th century. The price of tulip bulbs -- which look like grubby onions -- surged as much as 200% in just 14 months. Speculators sold their spectacular Amsterdam canal homes to buy tulip bulbs. Then the bubble popped and left the economy in ruins.

Since then, this pattern has repeated itself over and over again, in a wide variety of different assets.

Different market bubbles are developing all over the world. These will all eventually pop. Britain's departure from the European Union could be the pin for many of these bubbles (or it may cause some of them to inflate even more).

While we know it's impossible to time the market consistently, knowing the stages of a market bubble can help you decide when to get in and out of an investment. A typical market bubble has four stages:

    Stealth Phase: A small number of people and the "smart money" recognize a new investment opportunity.

      Awareness Phase: Prices increase as more people buy in. The media pick up on the story, giving it further exposure.

        Mania: Prices keep going up, and as the media continue to hype the story it seems certain that this will continue indefinitely. Investors, intoxicated by "easy money," irrationally project even bigger future gains.

          Blow-Off: Prices taper off. People start to see that prices have lost touch with reality. The media turns negative on the idea. The bubble pops. Prices fall dramatically and buyers disappear. A negative feedback loop confirms suspicions. Prices typically drop by about 50% but can fall below prebubble levels.

          You can use this pattern to your advantage as bubbles develop in markets around the world.

          Get in During the Stealth Phase

          One of the most respected investors in history, George Soros, said in 2009: "When I see a bubble forming, I rush in to buy, adding fuel to the fire."

          Finding a promising investment angle with bubble potential is key. An example is the Chinese stock market. In August 2014, the Chinese government faced a slowing economy. It lowered margin account rates. And the state-controlled media ran stories about the potential gains from China's stock market.

          The "smart money" saw that the Chinese government was trying to manipulate prices and jumped on the opportunity. On Aug. 29, 2014, the Shanghai Composite Index was at 2217. It then gained 133% in just 10 months, reaching 5166 on June 12, 2015.

          In a similar case, the U.S. government used quantitative easing to address growing concerns about slow postrecession economic growth. At the beginning of 2009, the Federal Reserve announced that it would start buying $1 trillion worth of U.S. Treasury bonds to support the economy. It initiated the first round of quantitative easing that March.

          Since they knew what would happen when the Fed started pumping money into the economy, the smart money knew it was "risk on," or a good time to own stocks. And they were right. The first round of quantitative easing ran from March 2009 to April 2010, and during that time the S&P 500 climbed 70%.

          The Awareness Phase Is the Next-Best Time to Invest

          The aim is to enter the market before the irrational mania begins.

          Even though the first round of quantitative easing caused a spike in stock prices, the U.S. economy was sluggish by September 2011. U.S. stocks were not doing well. The market and investors became bearish. Then the Fed announced "QE2," a second round of money printing.

          To figure out what might happen, the smart money looked at the only precedent of quantitative easing: Japan in the 2000s.

          Japan's Nikkei jumped 50% after its QE1. It climbed another 80% after Japan's QE2. So, another round of U.S. quantitative easing could do the same thing for U.S. markets. And things played out exactly as they did in Japan. The S&P 500 gained 20% in six months.

          If You Miss the Stealth and Awareness Phases, Wait for the "Inverse Bubble"

          Irrational enthusiasm can make prices surge higher than economic reality. But inversely, irrational pessimism can push prices excessively low because of too much selling.

          People have short financial memories. They want to forget the market plunge of 2008 and 2009. But the recent Brexit selloff might jog their memories. (The day after Great Britain voted to leave the EU, global stock markets lost more than $2 trillion in value.)

          While markets are jittery, and bordering on panic mode, make a list of companies you want to own. Determine what price you would consider a bargain for them. Then, if panic causes share prices to drop to those levels, buy.

          Stay Away From Markets During the Mania Phase

          It takes a lot of self-control to leave a great party. But, in the words of country singer Kenny Rogers, to be a good investor "you gotta to know when to hold 'em and know when to fold 'em."

          Take the Shanghai Composite example. On April 10, 2015, the index broke 4000. In eight months it was up about 80%. Investors (mostly unsophisticated traders) were buying up everything. In six months, margin lending increased 250% to record levels. Brokers were opening 4 million new trading accounts a week to keep up with demand.

          The People's Daily, the official newspaper of China's Communist Party, assured everyone this was just the beginning of the bull market.

          Two months later, the Shanghai Composite reached a peak of 5166. In 10 months, it was up by about 130%.

          Image placeholder title

          According to a Legg Mason and Citibank survey, the Chinese were the most optimistic investors in the world. People from mainland China borrowed $348 billion to buy more stocks. About 60% of them wanted to buy more equities within the next year.

          All the while, China's economy was expanding at its lowest rate since 1990. Price-to-earnings ratios (a popular method used to determine how expensive stocks are) were at five-year highs. China's Shenzhen Stock Exchange, known for its tech companies, had half of its stocks with analyst coverage with forward P/Es over 50. Half of all Shenzhen Exchange stocks had at least doubled in price during the previous year.

          The head of a financial research firm in Hong Kong said, "We have a wonderful bubble on our hands. Of course, there's short-term money to be made. But I fear it will not end well."

          He was right about two things: There was a bubble and it did not end well. Within a month after hitting its peak, the Shanghai Composite had fallen 32%. By Jan. 28, 2016 it was down 48%.

          You would have needed impeccable timing to realize any short-term gains.

          To profit from market bubbles, know the phases. If you get in early, wait for your Uber driver or barista or financially illiterate brother-in-law to start giving you stock tips. Those could be good indicators of the market reaching the mania phase. That's when you want to start selling, sit on your gains and wait for the bubble to pop.

          A key to avoiding losing money to market bubbles is controlling our emotions. We prepared a special report that explains how to control some of the cognitive biases that affect investment decisions. You can download it here.

          Kim Iskyan is the founder of Truewealth Publishing, an independent investment research company based in Singapore. Click here to sign up to receive the Truewealth Asian Investment Daily in your inbox every day, for free.

          This article is commentary by an independent contributor. At the time of publication, the author held no positions in the stocks mentioned.