This document contains code to backtest a moving average trading strategy on S&P 500 index data from 2000-2010. It defines a TradingStrategy function that calculates signals based on short and long moving averages, and returns the daily profits/losses of following those signals. It then runs the TradingStrategy over a range of moving average periods, calculates performance metrics for each, and selects the top 5 strategies based on Sharpe ratio. The best strategy from the training period is then tested out of sample on new data to see how it performs versus a buy and hold approach.