Posts Tagged ‘technical analysis’

The Every Pattern Ever Engine

August 28th, 2008

Around my sophomore year of college, I wrote an application to analyze technical analysis trading patterns. I read a few books on technical analysis and thought they were horribly unsophisticated. For the most part I found that technical analysis books were basically if match(patternX) then take(positionY).

I had not yet reached any mathematical sophistication, so I did not liken chart pattern trading to tea leaf reading. I did, however, wonder why they relied on this one set of chart patterns if others, especially those not published, might exist.

To satisfy my curiosity, I built an application that constructed every pattern that ever occurred in the listed SP500 stocks since 1980. It was actually fun to write and remarkably fast after all the graph indexes were created. I could choose to set how many days would define a pattern, how close the movements would need to be to considered a match, the importance of relative volumes, and countless other measure that I have long since forgotten.

Returns were based on either holding for a static period length; holding until history suggested deviation from the past pattern and all newly matching patterns suggested movement against my position; and other plays that I can no longer remember. After all matches had been assembled and all returns were generated, I could browse the resulting return distributions for each unique pattern. The result: many appeared to be very profitable but the overall return out of sample was close enough to zero to be discouraging (I am purposely ignoring my current knowledge of statistics for this presentation).

I then went a bit further and looked up trading patterns mentioned in all the fantastic technical analysis books. It was clear that they were no more likely to be included in the strong, in-sample returns set than any random pattern. My intuition was correct; Technical analysis was unsophisticated and, simply, tea leaf reading.

Granted, the experience was incredibly useful and worthwhile. I would not discourage anyone from repeating my experiment; You will learn A LOT. It helps build an intuition for statistical inference prior to studying statistical inference — although studying statistical inference first is not a bad idea.

Many of my subsequent experiments were heavily shaded by this early experiment; Many posts will echo lessons learned.