Tag: Bollinger Bands

Algorithmic Trading Model for Mean-Reversion with Bollinger Bands and Stop Loss Signals 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 employs a simple mean-reversion strategy using the Bollinger Bands as the entry and exit signals. The model will use a trend window size of 20 days for long trades only. When the stock price reaches the lower band, the model will initiate a long position. Conversely, the model will exit that long position when the stock price reaches the upper band. In addition, the model will also generate an exit signal when the holding reaches a 10% loss at the end of the day. Finally, we will compare two models where one model has a 10% stop-loss limit while the other does not.

ANALYSIS: In this modeling iteration, we analyzed ten stocks between January 1, 2016, and August 6, 2021. The models’ performance appeared at the end of the script. Also, the models without stop-loss produced a better return six out of the ten stocks. Moreover, the simple buy-and-hold approach came out ahead for all stocks except one.

CONCLUSION: For most stocks during the modeling time frame, the long-only trading strategy with Bollinger Bands did not produce a better return than the buy-and-hold approach. We should consider modeling these stocks 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.

Algorithmic Trading Model for Trend-Following with Bollinger Bands Strategy Using Python Take 4

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 mean-reversion strategy for a stock. The model enters a position when the price reaches either the upper or lower Bollinger Bands for the last X number of days. The model will exit the trade when the stock price crosses the middle Bollinger Band of the same window size.

In iteration Take1, we set up the models using a trend window size for long trades only. The window size varied from 10 to 50 trading days at a 5-day increment, and we fixed the Bollinger Band factor at 2.0.

In iteration Take2, we set up the models using a trend window size for long and short trades. The window size varied from 10 to 50 trading days at a 5-day increment, and we fixed the Bollinger Band factor at 2.0.

In iteration Take3, we experimented with different Bollinger Band factors from 1.0 to 3.0. The models still used a trend window size for long trades only. The window size varied from 10 to 50 trading days at a 5-day increment.

In this Take4 iteration, we will experiment with different Bollinger Band factors from 1.0 to 3.0. The models will use a trend window size for long and short trades. The window size will vary from 10 to 50 trading days at a 5-day increment.

ANALYSIS: In iteration Take1, we analyzed the stock prices for Costco Wholesale (COST) between January 1, 2016, and May 7, 2021. The top trading model produced a profit of 101.66 dollars per share. The buy-and-hold approach yielded a gain of 223.02 dollars per share.

In iteration Take2, we analyzed the stock prices for Costco Wholesale (COST) between January 1, 2016, and May 7, 2021. The top trading model produced a profit of -1.26 dollars per share. The buy-and-hold approach yielded a gain of 223.02 dollars per share.

In iteration Take3, we analyzed the stock prices for Costco Wholesale (COST) between January 1, 2016, and May 7, 2021. The top trading model produced a profit of 138.21 dollars per share. The buy-and-hold approach yielded a gain of 223.02 dollars per share.

In this Take4 iteration, we analyzed the stock prices for Costco Wholesale (COST) between January 1, 2016, and May 7, 2021. The top trading model produced a profit of 42.91 dollars per share. The buy-and-hold approach yielded a gain of 223.02 dollars per share.

CONCLUSION: For the stock of COST during the modeling time frame, the long-and-short trading strategy with variable Bollinger Band factors 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.

Algorithmic Trading Model for Trend-Following with Bollinger Bands 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 mean-reversion strategy for a stock. The model enters a position when the price reaches either the upper or lower Bollinger Bands for the last X number of days. The model will exit the trade when the stock price crosses the middle Bollinger Band of the same window size.

In iteration Take1, we set up the models using a trend window size for long trades only. The window size varied from 10 to 50 trading days at a 5-day increment, and we fixed the Bollinger Band factor at 2.0.

In iteration Take2, we set up the models using a trend window size for long and short trades. The window size varied from 10 to 50 trading days at a 5-day increment, and we fixed the Bollinger Band factor at 2.0.

In this Take3 iteration, we will experiment with different Bollinger Band factors from 1.0 to 3.0. The models will use a trend window size for long trades only. The window size will vary from 10 to 50 trading days at a 5-day increment.

ANALYSIS: In iteration Take1, we analyzed the stock prices for Costco Wholesale (COST) between January 1, 2016, and May 7, 2021. The top trading model produced a profit of 101.66 dollars per share. The buy-and-hold approach yielded a gain of 223.02 dollars per share.

In iteration Take2, we analyzed the stock prices for Costco Wholesale (COST) between January 1, 2016, and May 7, 2021. The top trading model produced a profit of -1.26 dollars per share. The buy-and-hold approach yielded a gain of 223.02 dollars per share.

In this Take3 iteration, we analyzed the stock prices for Costco Wholesale (COST) between January 1, 2016, and May 7, 2021. The top trading model produced a profit of 138.21 dollars per share. The buy-and-hold approach yielded a gain of 223.02 dollars per share.

CONCLUSION: For the stock of COST during the modeling time frame, the long-only trading strategy with variable Bollinger Band factors 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.

Algorithmic Trading Model for Trend-Following with Bollinger Bands Strategy Using Python 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 examines a simple mean-reversion strategy for a stock. The model enters a position when the price reaches either the upper or lower Bollinger Bands for the last X number of days. The model will exit the trade when the stock price crosses the middle Bollinger Band of the same window size.

In iteration Take1, we set up the models using a trend window size for long trades only. The window size varied from 10 to 50 trading days at a 5-day increment, and we fixed the Bollinger Band factor at 2.0.

In this Take2 iteration, we will set up the models using a trend window size for long and short trades. The window size will vary from 10 to 50 trading days at a 5-day increment, and we will fix the Bollinger Band factor at 2.0.

ANALYSIS: In iteration Take1, we analyzed the stock prices for Costco Wholesale (COST) between January 1, 2016, and May 7, 2021. The top trading model produced a profit of 101.66 dollars per share. The buy-and-hold approach yielded a gain of 223.02 dollars per share.

In this Take2 iteration, we analyzed the stock prices for Costco Wholesale (COST) between January 1, 2016, and May 7, 2021. The top trading model produced a profit of -1.26 dollars per share. The buy-and-hold approach yielded a gain of 223.02 dollars per share.

CONCLUSION: For the stock of COST during the modeling time frame, the long-and-short trading strategy with fixed Bollinger Band factor 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.

Algorithmic Trading Model for Trend-Following with Bollinger Bands Strategy Using Python Take 1

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 mean-reversion strategy for a stock. The model enters a position when the price reaches either the upper or lower Bollinger Bands for the last X number of days. The model will exit the trade when the stock price crosses the middle Bollinger Band of the same window size.

In this Take1 iteration, we will set up the models using a trend window size for long trades only. The window size will vary from 10 to 50 trading days at a 5-day increment, and we will fix the Bollinger Band factor at 2.0.

ANALYSIS: In this Take1 iteration, we analyzed the stock prices for Costco Wholesale (COST) between January 1, 2016, and May 7, 2021. The top trading model produced a profit of 101.66 dollars per share. The buy-and-hold approach yielded a gain of 223.02 dollars per share.

CONCLUSION: For the stock of COST during the modeling time frame, the long-only trading strategy with fixed Bollinger Band factor 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.