Simple Moving Average Long Strategy
First, we will load the python packages.
Previously we did two videos on LSTM long strategies – one using classification approach and one using regression approach. We seem to achieve a rather decent Sharpe ratio of about 0.9 for the LSTM regression long strategy. In this video, we shall demonstrate the traditional Simple Moving Average long strategy for comparison.
The first few steps are identical to my previous video, so I will not repeat it over here. For apple to apple comparison, we will backtest on the same MFST dataset.
We compute the simple moving average of 20 days. We define the signal for a long position if the previous Adj Close price is larger than the previous simple moving average, else the signal will be no position.
We compute the strategy returns and entry points similar to the previous video.
There are a lot more trades using the simple moving average strategy as compared to the LSTM strategies, We did a zoom in and we could see the buy and sell signals were consistent with the strategy.
If we compare the strategy returns and bnh returns, this strategy did not perform well. We got a Sharpe ratio of 0.56 and a max drawdown of 57% which were worse than the previous LSTM long regression strategy.
The code can be downloaded below
Recommended trading platforms
Recommended courses on Algorithmic Trading
1. Basic Algorithmic Trading with Python
2. Machine Learning for Algorithmic Trading
https://www.tertiarycourses.com.sg/machine-learning-for-algorithmic-trading.html https://www.tertiarycourses.com.my/machine-learning-for-algorithmic-trading-malaysia.html https://www.tertiarycourses.com.gh/machine-learning-for-algorithmic-trading-ghana.html