Hi All,

I'd like to share with you a simple mean reversion technique that relies on moving averages. In short, the idea is that the mean-reversion signals can be approximated by intersections of different-length moving averages. This is best made clear by the following illustration:

http://i.imgur.com/5oi3yao.png

In which the data is from a 3,000-day dataset of a stock's closing price. In this model, we generally have one "long" moving average and one "short" moving average (in this case, 90 and 30 days, respectively). We trade when these lines intersect, then choosing to buy or sell based on the direction of the trend (whether the short MA is rising or falling). I note that we don't trade *exactly* when the lines intersect, but rather when they are sufficiently close (by some user-defined metric). While this is not as statistically strong as mean reversion could be, it's a reasonable approximation with plenty of nice properties because of the lag between the two MAs: a reasonable buy/sell strategy with clear signals that translates into having an effective stop-loss from any peak, except for cases of sudden and severe price crashes.

I've attached a backtest that I ran on some tech stocks between 2008 and 2010, with MA periods of 30 and 10 days.

I'm somewhat new to Quantopian and I didn't have much time to write my algorithm, so I apologize for some of the crude techniques I used in my code, which I intend to fix in future versions. I plan to rewrite the part that decides how much to invest (it's currently mostly hand-tuned with guesstimates), to add a more sophisticated stop-loss, and and to improve the heuristic for determining whether a security is trending negatively or positively. I also need to make my algorithm start shorting stocks. There's generally a great deal of calibration to be done to this algorithm. It would also probably be useful to develop some analyses that determine the best MA periods to use.

Feel free to play around with this algorithm and see if you find anything interesting!