Algorithmic Trading Model for Moving Average Crossover Mean-Reversion Strategy with Volume Indicator Using Python

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: This project aims 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. The MA models fall under one of two trading approaches: momentum and mean-reversion. This iteration of modeling will focus on applying the models to the mean-reversion approach.

For the mean-reversion approach, the strategy goes long (buys) when the fast moving-average curve crosses below the slow moving-average curve. When the opposite occurs, we will exit the position. Furthermore, we will use the trading volumes to confirm the buy and sell signals by comparing them to the 10-day moving average.

ANALYSIS: From this iteration, we analyzed the stock prices for Johnson and Johnson (JNJ) between January 1, 2019, and December 11, 2020. The trading model produced a profit of 48.42 dollars per share. The buy-and-hold approach yielded a gain of 23.40 dollars per share.

CONCLUSION: For the stock of JNJ during the modeling time frame, the trading strategy produced a better return than the buy-and-hold approach. We should consider modeling this stock further by experimenting with more variations of the strategy.

Dataset ML Model: Time series analysis with numerical attributes

Dataset Used: Quandl

The HTML formatted report can be found here on GitHub.