# Algorithmic Trading Model for Combo Moving Average Crossover Grid Search Take 3

NOTE: This script is for learning purposes only and does not constitute a recommendation for buying or selling any stock mentioned in this script.

SUMMARY: The purpose of this project is to construct and test an algorithmic trading model and document the end-to-end steps using a template.

INTRODUCTION: This algorithmic trading model examines a series of exponential and simple moving average (MA) crossover models via a grid search methodology. This iteration of the modeling will focus on applying a trend-following or a momentum-oriented approach. When the fast moving-average curve crosses below the slow moving-average curve, the strategy goes long (buys) on the stock. When the opposite occurs, we will exit the position.

From iteration Take1, the grid search script searched through all combinations between the two sets of MA curves, simple and exponential. The faster MA curve ranged from 5 days to 30 days, while the slower MA ranged from 10 days to 60 days. Both curves used a 5-day increment.

From iteration Take2, the grid search script searched through all combinations between the four sets of MA curves. The four models were simple only, exponential only, fast simple/slow exponential, and fast exponential/slow simple. The fast MA curve ranged from 5 days to 30 days, while the slow MA ranged from 10 days to 60 days. All four sets of curves used a 5-day increment.

For this Take3 iteration, the grid search script will search through all combinations between the two sets of MA curves, simple and exponential. The faster MA curve can range from 5 days to 30 days, while the slower MA can range from 10 days to 60 days. Both curves use a 5-day increment.

ANALYSIS: From iteration Take1, we analyzed the stock prices for Apple Inc. (AAPL) between January 1, 2019 and August 3, 2020. The best simple MA model with 10-day and 20-day produced a profit of 284.11 per share. The best exponential MA model with 5-day and 20-day produced a gain of 280.73. The long-only approach yielded a gain of 280.86 per share.

From iteration Take2, we analyzed the stock prices for Apple Inc. (AAPL) between January 1, 2019 and August 3, 2020. The best MA model with 5-day EMA and 30-day SMA produced a profit of 289.28 per share. The long-only approach yielded a gain of 280.86 per share.

For this Take3 iteration, we analyzed the stock prices for Apple Inc. (AAPL) between January 1, 2019 and August 3, 2020. The best simple MA model with 30-day and 60-day produced a profit of 97.39 per share. The long-only approach yielded a gain of 280.86 per share.

CONCLUSION: For AAPL and during the modeling time frame, the mean-reversion approach produced a suboptimal return when compared to the momentum-oriented and long-only approaches. In this case, the buying-and-holding strategy is much more profitable without too much fuss.

Dataset ML Model: Time series analysis with numerical attributes

Dataset Used: Quandl

The HTML formatted report can be found here on GitHub.