Algorithmic Trading Model using Weekly MACD and RSI Indicators

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 Moving Average Convergence/Divergence Oscillator (MACD) and Relative Strength Index (RSI) for the entry and exit signals. For the MACD trend indicators, the model will use 12-week and 26-week periods for the MACD line. For the MACD signal line, we will use a 9-week EMA of the MACD line. Finally, the RSI will operate using a 14-week look-back period.

The model will signal for a long position when the MACD histogram switches from negative to positive, assuming the RSI signal is below the overbought threshold. Conversely, the model will look to initiate a short position when the signals reverse themselves.

We will compare two trading models with different buying approaches. The first model will use a long-only method, while the second model will take long and short positions. Both models will use a 10% stop-loss limit for each trade.

ANALYSIS: In this modeling iteration, we analyzed ten stocks between October 1, 2011, and October 1, 2021. The models’ performance appeared at the end of the script. The models with the long-only approach produced a better return than the long-short method. Moreover, the simple buy-and-hold system came out ahead for all stocks.

CONCLUSION: For most stocks during the modeling time frame, the customized trading strategy with the MACD and RSI signals 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 using Daily MACD and RSI Indicators

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 Moving Average Convergence/Divergence Oscillator (MACD) and Relative Strength Index (RSI) for the entry and exit signals. For the MACD trend indicators, the model will use 12-day and 26-day periods for the MACD line. For the MACD signal line, we will use a 9-day EMA of the MACD line. The RSI will operate using a 14-day look-back period.

The model will signal for a long position when the MACD histogram switches from negative to positive, assuming the RSI signal is below the overbought threshold. Conversely, the model will look to initiate a short position when the signals reverse themselves.

We will compare two trading models with different buying approaches. The first model will use a long-only method, while the second model will take long and short positions. Both models will use a 10% stop-loss limit for each trade.

ANALYSIS: In this modeling iteration, we analyzed ten stocks between October 1, 2011, and October 1, 2021. The models’ performance appeared at the end of the script. The models with the wider signal line width generally produced a better return for the tested stocks. Moreover, the simple buy-and-hold approach came out ahead for all stocks.

CONCLUSION: For most stocks during the modeling time frame, the customized trading strategy with the MACD and RSI signals 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 using Force Index with Stop Loss

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 uses force index indicators to employ a simple mean-reversion strategy for stock position entries and exits. For the Force Index indicator, the model will use a 13-period indicator for the trading signal. The model will initiate a long position when the trading indicator turns from negative to positive. Conversely, the model will exit the long position when the signal indicator turns from positive to negative.

Moreover, one of the two models will exit the long position when a 10-percent stop-loss triggers. We will evaluate the effectiveness of using a stop-loss trigger by comparing the portfolio results to the model without the stop-loss trigger.

ANALYSIS: In this modeling iteration, we analyzed ten stocks for ten years between September 1, 2011, and September 24, 2021. The models’ performance appeared at the end of the script. The models with the wider signal line width generally produced a better return for the tested stocks. Moreover, the simple buy-and-hold approach came out ahead for all stocks.

CONCLUSION: For most stocks during the modeling time frame, the long-only trading strategy with the Force Index 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 using Force Index with Different Periods

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 for stock position entries and exits using force index indicators. For the Force Index indicator, the model will use a 13-period and a 50-period indicator for the trading signal. The model will initiate a long position when the trading indicator turns from negative to positive. Conversely, the model will exit the long position when the signal indicator turns from positive to negative.

ANALYSIS: In this modeling iteration, we analyzed ten stocks between August 1, 2016, and September 17, 2021. The models’ performance appeared at the end of the script. The models with the wider signal line width generally produced a better return for the tested stocks. Moreover, the simple buy-and-hold approach came out ahead for all stocks.

CONCLUSION: For most stocks during the modeling time frame, the long-only trading strategy with the Force Index 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 using Stochastic RSI with Different Signal Levels

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 Stochastic RSI (StochRSI) indicators for stock position entries and exits. For the Stochastic RSI indicator, the model will use a 14 look-back period. The model will initiate a long position when the indicator crosses the lower signal line from above. Conversely, the model will exit the long position when the indicator crosses the upper signal line from below.

ANALYSIS: In this modeling iteration, we analyzed ten stocks between August 1, 2016, and September 10, 2021. The models’ performance appeared at the end of the script. The models with the wider signal line width generally produced a better return for the tested stocks. Moreover, the simple buy-and-hold approach came out ahead for all stocks.

CONCLUSION: For most stocks during the modeling time frame, the long-only trading strategy with the Stochastic RSI signals 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.

CONCLUSION: For most stocks during the modeling time frame, the long-only trading strategy with the Stochastic Oscillator signals 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 using Stochastic Oscillator with Different Signal Levels

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 Stochastic Oscillator indicator for the entry and exit signals. The model will use a 14 look-back period with a three-period Simple Moving Average (SMA) for the %K indicator. The model also will use a three-period SMA of the %K indicator for the %D indicator. Thus, the model will initiate a long position when the %D indicator crosses the lower signal line from above. Conversely, the model will exit the long position when the %D indicator crosses the upper signal line from below.

We will compare two trading models with different signal line widths. The first model will use 20/80 for the lower and upper signal lines. The second model will use a tighter 20/50 for the lower and upper signal lines.

ANALYSIS: In this modeling iteration, we analyzed ten stocks between August 1, 2016, and September 3, 2021. The models’ performance appeared at the end of the script. The models with the wider signal line width generally produced a better return for the tested stocks. Moreover, the simple buy-and-hold approach came out ahead for all stocks.

CONCLUSION: For most stocks during the modeling time frame, the long-only trading strategy with the Stochastic Oscillator signals 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 Mean-Reversion with MACD 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 Moving Average Convergence/Divergence (MACD) indicator as the entry and exit signals. The model will use a 26-period Exponential Moving Average (EMA), a 12-period EMA, and a nine-period EMA as the signal line for long trades only. The model will initiate a long position when the long EMA line crosses the signal line from below. Conversely, the model will exit the long position when the long EMA line crosses the signal line from above.

ANALYSIS: In this modeling iteration, we analyzed ten stocks between August 1, 2016, and August 27, 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 MACD signals 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 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.