Keep good records in case you get sued or audited -- or if you just hope to learn from past experiences. It’s for that last reason (and, frankly, the second ... curse you, IRS!) that I keep meticulous records of my investments.

And so I found myself looking back over my recent transaction history. I wanted to see what I had done since October 2007 -- the beginning of what became a historic market downturn -- and what that behavior revealed about my state of mind during that tumultuous time ... and what we can learn from it.

So let’s take a trip back in time ...

October 2007 to May 2008
This was, for lack of a better term, the beginning of the end, but it was a fairly benign beginning. While the market was down 20% over this 8-month period, it was business as usual in my portfolio, with two or three buys per month into companies such as 3M (NYSE:MMM) and Starbucks (NASDAQ:SBUX) that I not only thought were compelling values, but also believed had the financial strength to survive a coming downturn.

And while I thought at the time that I was a rational master of my emotions, it’s more likely I was just getting duped by my amygdala. As Jason Zweig writes in Your Money and Your Brain, “Because the amygdala [the reflexive part of your brain] is so attuned to big changes, a sudden drop in the market tends to be more upsetting than a longer, slower decline.”

Either way, I'd say I handled the slow decline from October 2007 to May 2008 fairly well.

June 2008 to July 2008
Fast-forward two months, however, and the market began to test my mettle. I followed up a sharp near-10% decline in the market with a flurry of activity. But rather than sell in fear, I went aggressively long -- making 13 purchases of volatile international stocks such as Philip Morris (NYSE:PM) and China Fire & Security (NASDAQ:CFSG) that I believed had been unfairly oversold. Although it looked savvy at first as the market briefly perked up in August, this was a mistake.

It was not a mistake of fear, however, but rather one of greed. And while Zweig suggests that investors tend to get caught up in upward momentum, sending more and more money into the market as stock prices rise, I, as a conditioned value investor,  got greedy just as prices dropped sharply -- and ignored the data suggesting it could well get worse.

It did.

August 2008 to January 2009
The market declined 35%, creating what may end up being one of history’s great buying opportunities, and yet I couldn’t make more than a few buys here and there because I had used up my excess powder prematurely in July.

Thus, rather than being in a position to take advantage of this mega-drop, I was fully invested amid historic downside volatility. This led to some sleepless nights and some tough decisions in early February.

February 2009
If investing success is buying low and selling high, then failure is the opposite. And yet there I was in early February unloading stocks such as Whole Foods (NASDAQ:WFMI) and Sotheby’s (NYSE:BID) at 50% discounts to where I’d bought them.

Why? First, I was in too deep. My episode of greed in July had caused me to invest more money in stocks that I felt comfortable with. Thus, as the market continued to drop, I was unable to stay unemotional.

Second, I fell victim to recency bias. As Zweig writes, "The more recently [an event] occurred . . . the more probable its recurrence will seem." Put those two facts together and you can understand why my brain was pushing me to take some money out of the stock market.

Fortunately, I wasn’t totally shell-shocked. I only moved out a little -- enough to restore an analytical mindset. Further, rather than keep those sums 100% in cash, I put some in high-yield bonds, which were also distressed and which have not wholly missed out on the recent rebound (though they have not done as well as equities).

At the end of the day, these were defensive moves made out of fear, moves that depressed my returns. And while it frustrates me that I fell into one of investing’s psychological traps, I did end up realizing a benefit.

March 2009 to present
With investor equilibrium restored, it was back to business as usual in my portfolio with two or three purchases per month. And just as the market began to turn in March, I purchased shares of a speculative -- but, I believed, highly undervalued -- Chinese company called Yongye International (NASDAQ:YONG).

At the time it traded over-the-counter and did not yet have a CFO or any independent directors on its board. The stock, however, was dirt cheap at $1.70 per share.

Now, if I hadn’t rebalanced my portfolio in February, I don’t think I would have had the gumption to purchase this stock. But I was back in my comfort zone, and I was able to pull the trigger.

I’m glad I did. Yongye has since added a number of qualified individuals to its management team and listed on the Nasdaq. Further, our Global Gains team visited Yongye in China in June to get a better handle on the business -- after which we called it out as a top pick to our Global Gains members.

Yongye now trades for more than $8 per share. I don’t write this to gloat or cherry-pick, but rather to highlight the importance of having -- at all times -- a balanced portfolio that allows you to make decisions untainted by emotion.

The takeaways
That’s my story, but there are three key takeaways for you as well. Here they are:

1. Never go all in.
I acted too soon in July, and that reduced my flexibility, as well as my ability to remain unemotional going forward.

2. Add money to the market on a regular basis.
Despite all of the research I’d read and all of the contacts I have, I was unable to anticipate the market’s near-term moves. I would have saved myself a lot of stress if I had stuck to regular buys of great companies at great prices.

3. Diversification matters.
Whether it’s stocks or bonds, domestic or foreign stocks, or small caps or large caps, the defense that diversification provides truly does provide peace of mind in times of crisis. Not only does it help you lose less money as the market’s falling, but it can also allow you to stay unemotional and analytical -- enabling you to take advantage of incredible opportunities such as Yongye whenever they present themselves.

We employ all of these lessons at Motley Fool Global Gains, where our team of analysts seeks to find value in the world’s very volatile emerging markets. And while 2009 has been a particularly volatile year for us, stocks like Yongye more than make up for it. To take a look at all of our research and recommendations, simply click here to join Global Gains free this month.

Already subscribe to Global Gains? Log in at the top of this page.

Tim Hanson is co-advisor of Motley Fool Global Gains. He owns shares of Yongye International, 3M, and Philip Morris. Sotheby’s is a Motley Fool Hidden Gems selection. Philip Morris is a Global Gains recommendation. Starbucks and 3M are Inside Value picks. Whole Foods and Starbucks are Stock Advisor picks. The Motley Fool owns shares of Starbucks and has this disclosure policy to make sure all of our analysts keep meticulous records.