Tuesday, February 21, 2012

Martingale Lessons

In the spring of 2011, there was no denying it. I adopted a decidely jaded view of the stock market and had grown to despise an industry full of self proclaimed oracles. Most of these people in my view were a bunch of textbook salesmen and women selling various dreams of financial security and fame.

Through sheer stubborness I remained invested and recovered from the down years of 2008 and 2009. However, single digit gains were taxing my patience. I was miles from my longterm goals. There was no doubt I would be working well into my 60s and if I suffered any type of dementia, it was not hard to imagine myself greeting people at Walmart. When I stumbled upon Forex, you could say I was open to a change.

The Allure of the Martingale



Through my work as an expert advisor programmer, I became involved in coding all manner of peoples trading strategies into small trading robots called expert advisors or custom indicators. I am still surprised by all the permutations of indicators, chart patterns, money management mechanisms, etc, that trader are dreaming up out there.

I would code them all up according to their specifications, slap them in a backtester to put them through their paces, fix any problems. Rinse and repeat until all was working to everyone's satisfaction. Many if not most were flawed for one reason or another, some would work exceptionally well in one type of market but perform poorly in others.

Some were tied to faulty indicators that would change their earlier output signals. Some were based on what I viewed as various arcane chart patterns which seemed one step removed (no pun intended) from witchcraft. Others were complex to the point where they would rarely trade and when they did would do so at the most inopportune time.

After perhaps a year of this, I received a Martingale strategy to code for an overseas customer. After coding and running his EA in the strategy tester, I remember becoming very excited with how well it was performing on every time period and data set in all markets. I spent more time testing this EA that day than most, even though I was not finding any problems with the coding. After seeing so many crash and burn that week, I enjoyed watching it do its thing.

To be sure, it was not the first Martingale I had seen and I had always discounted that ilk as being to closely tied to Vegas and gambling. But, like the ones I had seen before, it was doing a bangup job of piling up cash during my test runs. I guess after seeing the nth Martingale doing that I could no longer ignore this method of trading.

That afternoon and for many days following, whenever my thoughts would wander ideas would pop into my head as to what sort of Martingale I would program in MetaTrader for myself. It was truly something of an epiphany. Up to that point my whole view of forex was that of a high stakes market best left to big banks, institutional investors, and governments. I had never thought of running one of these programs on my own money.

Like most Martingales, mine would double its lot size with every loss. I suppose what was different about my Martingale from many but certainly not all others, is that mine would reverse the direction of its trades. This would solve trending markets, the achilles heal of single-direction-trade martingales. It would also use a Take Profit and Stop Loss that would be somewhat sensitive and self-adjusting to Average True Range. This was my answer to excessive volatility. Finally, I put in logic to have hidden take profits and stops. This would satisfy my probably unwarranted suspicion of brokers.

I'm not going to get too detailed on leverage, margin requirements and such. With a Martingale, you need to consider how many levels you're going to let it go before it gives up or resets its lot size. And don't kid yourself; it will go deep more often then you would think. You need to make sure you have enough money in a Martingale trading account to support your biggest possible trade.

Happy Days and Riding the Martingale bull



I went through the trouble of setting up a forex account and started trading. The first month felt underwhelming. I recall the EA only did a little better than breakeven but my enthusiasm was still intact. The fact that I did not lose any money comforted me, making it feel safe to press on.

I continued tweaking the EA and adjusting how I would use it. By the end of the 2nd month, mostly through trial an error I found the EA worked best on the EURUSD and the 15 min period. That's when the results started to give me that euphoria that I had so badly wanted. By the end of the fourth month, morale was sky high.

I'm not going to give actual numbers since I used to always suspect other type articles of fish tails when they did that, but it was enough to make me a changed person. If you can recall the nursery rhyme "Sing a Song of Sixpence". The line "The King was in his counting house, Counting out his money" pretty much sums it up. That was me. It almost felt illegal and I actually hid the results from others fearing that I would jinx everything if I mentioned it. I would often pick up a calculator or paper and pencil calculate out what the sum might be after 5 10 20 years at the current rate of returns.

When a Martingale goes bad



I'm not a market statistician or financial wizard of any sort, so I can't give a very elegant explanation of what happened. I do know that the financial problems in Europe during the fall of 2011 provided an extremely volatile and choppy market that did not agree with my reversing Martingale EA. It resulted in some whiplash-packed trading weeks and numerous reality checks.

All my gains for the year and then some were wiped out during a few weeks. The deceptive thing about a Martingale is that 99.9% of time it will look good and make money. When you test it, it is likely you won't catch it at its worst. It feeds a sense of denial. In this case results were good for several months before it lost money.

Once it starts losing, the trades become big very quickly. If you happen to be asleep when this happens, you're in for a big surprise as you rub the sleep from your eyes and peer at your monitor in the morning. I know some of you are thinking, "well, duh", and to be honest, knowledge of this possibility was always in the back of my head. I thought since the Martingale was a reversing one and would adjust to volatility I was at least somewhat immune to this. I suppose it could have been much worse with a more conventional Martingale.

Another thing to watch out for is meddling. When things started going bad I slipped into the bad habit of supervising the EA. I would stop trades just before they were about to recover and the net result was usually to make things worse.

Summary



Since that time, I have scaled back use of the Martingale. In some type markets I won't even run it. I also added a non trading window feature to it. Specifically I can set it up to shut itself down at specific times of the day. Now when I go to bed, if there are multiple big financial news reports scheduled for the morning, I set the EA to go inactive before and for sometime after this time to let the associated volatility work itself out.

I sleep better when I know it won't be running at night. It's no longer producing killer returns for me as the volatility will usually make you money, but I don't have to worry so much about the times when it will create losses, either. There's a price to pay for peace of mind. If that means trading less often, I'm all in favor.