Algorithmic Trading Model using Weekly Price and Simple Moving Average Take 2

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 employs a simple strategy using the weekly price and simple moving average (SMA) for the entry and exit signals. For the SMA line, the model will use 50 days. The model will signal a long position when the weekly price crosses from below the SMA line to above. Conversely, the model will exit the long position when the weekly moves below the SMA line. The model will deploy all of its available capital per transaction to compare strategies.

ANALYSIS: In this modeling iteration, we analyzed thirteen Exchange-Traded Funds (ETF) for five years between January 1, 2017, and December 31, 2021. The models’ performance appeared at the end of the script. The buy-and-hold model generally produced a better return for the tested equities. However, the algorithmic trading model only comes out ahead with the energy sector ETF (XLE).

CONCLUSION: For most stocks during the modeling time frame, the customized trading strategy with the Weekly Price and Simple Moving Average did not produce a better return than the buy-and-hold approach. We should consider modeling these stocks further by experimenting with more strategy variations.

Dataset ML Model: Time series analysis with numerical attributes

Dataset Used: Sharadar US Equities and Fund Prices hosted by Quandl/Nasdaq Data Link

The HTML formatted report can be found here on GitHub.