# Algorithmic Trading Model for Simple Trend-Following Strategy Using Python 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: 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 simple trend-following strategy for a stock. The model buys a stock when the price reaches the highest price for the last X number of days. The model will exit the position when the stock price crosses below the mean of the same window size.

From iteration Take1, we set up the models using one fixed window size for long trades only. The window size varied from 10 to 50 trading days at a 5-day increment.

From iteration Take2, we set up the models using one fixed window size for long trades only. The window size will vary from 10 to 50 trading days at a 5-day increment. The models also considered a volume indicator with its window size to confirm the buy/sell signal.

In this Take3 iteration, we will set up the models using one fixed window size for long and short trades. The window size will vary from 10 to 50 trading days at a 5-day increment.

ANALYSIS: From iteration Take1, we analyzed the stock prices for Apple Inc. (AAPL) between January 1, 2019, and December 24, 2020. The trading model produced a profit of 81.49 dollars per share. The buy-and-hold approach yielded a gain of 92.60 dollars per share.

From iteration Take2, we analyzed the stock prices for Apple Inc. (AAPL) between January 1, 2019, and December 24, 2020. The trading model produced a profit of 82.47 dollars per share. The buy-and-hold approach yielded a gain of 92.60 dollars per share.

In this Take3 iteration, we analyzed the stock prices for Apple Inc. (AAPL) between January 1, 2019, and December 24, 2020. The trading model produced a profit of 79.95 dollars per share. The buy-and-hold approach yielded a gain of 92.60 dollars per share.

CONCLUSION: For the stock of AAPL during the modeling time frame, the trading strategy did not produce 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.