banner

Developing and testing a custom algorithmic trading strategy using exponential moving average, relative strength index, and sentiment analysis

Sstuti D. Mehra, Sujala D. Shetty

Abstract


Stock trading is a popular and important profession that requires near-to-perfect data analytical skills, mathematical and statistical knowledge, and a broad understanding of buying and selling stocks. Often, due to the number of factors to consider and the intervention of human bias, traders and investors make wrong decisions that cost them millions of dollars. Therefore, automated algorithmic trading has gained traction in the marketplace due to its ability to process huge amounts of data, perform mathematical calculations and make quick and effective decisions. Most algorithmic trading strategies rely on a single technical indicator; however, it has been found that combining two or more indicators makes a trading strategy profitable. Therefore, this paper proposes a custom algorithmic trading strategy that combines important technical indicators such as the Exponential Moving Average and Relative Strength Index and utilizes sentiment analysis of financial news as well. This combination of technical indicators and sentiment analysis is not prevalent in existing research. The performance of the strategy was tested on fifteen stocks from different sectors of the US market using Python’s VectorBt library. The results showed that most of the stocks produced a higher win rate with the custom strategy as compared to other strategies, with the highest win rate of 88% for the S&P 500 index. To carry out sentiment analysis, a NLP model using BERT was developed which achieved an accuracy of 84%. Finally, to test the strategy on real-time data, paper trading was carried out on the Alpaca API and after six months the portfolio’s ROI is 6.26%.


Keywords


stocks; algorithmic trading; trading strategies; exponential moving average; relative strength index; sentiment analysis; backtesting; paper trading

Full Text:

PDF

References


1. Fazlija B, Harder P. Using Financial News Sentiment for Stock Price Direction Prediction. Mathematics. 2022, 10(13): 2156. doi: 10.3390/math10132156

2. Subrahmanyam A. Equity market momentum: A synthesis of the literature and suggestions for future work. Pacific-Basin Finance Journal. 2018, 51: 291-296. doi: 10.1016/j.pacfin.2018.08.004

3. Dai Z, Kang J, Wen F. Predicting stock returns: A risk measurement perspective. International Review of Financial Analysis. 2021, 74: 101676. doi: 10.1016/j.irfa.2021.101676

4. Bajaj V, Aghav J. Validating Algorithmic Trading Strategies to Predict Trends in Indian Index Option. Pune, India, 2016.

5. Ifleh A, El Kabbouri M. Stock price indices prediction combining deep learning algorithms and selected technical indicators based on correlation. Arab Gulf Journal of Scientific Research. Published online October 17, 2023. doi: 10.1108/agjsr-02-2023-0070

6. Salkar T, Shinde A, Tamhankar N, et al. Algorithmic Trading using Technical Indicators. 2021 International Conference on Communication information and Computing Technology (ICCICT). Published online June 25, 2021. doi: 10.1109/iccict50803.2021.9510135

7. Sahin U, Ozbayoglu AM. TN-RSI: Trend-normalized RSI Indicator for Stock Trading Systems with Evolutionary Computation. Procedia Computer Science. 2014, 36: 240-245. doi: 10.1016/j.procs.2014.09.086

8. Seshu V, Shanbhag H, Rao SR, et al. Performance Analysis of Bollinger Bands and Long Short-Term Memory(LSTM) models based Strategies on NIFTY50 Companies. 2022 12th International Conference on Cloud Computing, Data Science & Engineering (Confluence). Published online January 27, 2022. doi: 10.1109/confluence52989.2022.9734127

9. Khedr AE, S.E.Salama, Yaseen N. Predicting Stock Market Behavior using Data Mining Technique and News Sentiment Analysis. International Journal of Intelligent Systems and Applications. 2017, 9(7): 22-30. doi: 10.5815/ijisa.2017.07.03

10. Mehta P, Pandya S, Kotecha K. Harvesting social media sentiment analysis to enhance stock market prediction using deep learning. PeerJ Computer Science. 2021, 7: 476. doi: 10.7717/peerj-cs.476

11. Koroteev M. BERT: A review of applications in natural language processing and understanding. 22 March 2021. 10.48550/arXiv.2103.11943.

12. Faijareon C, Sornil O. Evolving and combining technical indicators to generate trading strategies. Journal of Physics: Conference Series. 2019, 1195: 012010. doi: 10.1088/1742-6596/1195/1/012010

13. Funde Y, Damani A. Comparison of ARIMA and Exponential Smoothing Models in Prediction of Stock Prices. The Journal of Prediction Markets. 2023, 17(1): 21-38. doi: 10.5750/jpm.v17i1.2017

14. Tang H, Dong P, Shi Y. A new approach of integrating piecewise linear representation and weighted support vector machine for forecasting stock turning points. Applied Soft Computing. 2019, 78: 685-696. doi: 10.1016/j.asoc.2019.02.039

15. Sarasa-Cabezuelo A. Development of a Backtesting Web Application for the Definition of Investment Strategies. Knowledge. 2023, 3(3): 414-431. doi: 10.3390/knowledge3030028

16. Smales LA. Investor attention and the response of US stock market sectors to the COVID-19 crisis. Review of Behavioral Finance. 2020, 13(1): 20-39. doi: 10.1108/rbf-06-2020-0138

17. Wojarnik G. Sentiment Analysis As A Factor Included In The Forecasts Of Price Changes In The Stock Exchange. Procedia Computer Science. 2021, 192: 3176-3183. doi: 10.1016/j.procs.2021.09.090

18. Bagate R, Joshi A, Trivedi A, et al. Survey on Algorithmic Trading Using Sentiment Analysis. Lecture Notes in Networks and Systems. Published online September 22, 2022: 241-252. doi: 10.1007/978-981-19-2225-1_22

19. Devlin J, Chang MW, Lee K, et al. Proceedings of the 2019 Conference of the North. Published online 2019. doi: 10.18653/v1/n19-1423

20. Malo P, Sinha A, Korhonen P, et al. Good debt or bad debt: Detecting semantic orientations in economic texts. Journal of the Association for Information Science and Technology. 2013, 65(4): 782-796. doi: 10.1002/asi.23062

21. Alpaca - Crypto, Stock Trading API. Available online: https://app.alpaca.markets/paper/dashboard/overview (accessed on 20 May 2023).




DOI: https://doi.org/10.32629/jai.v7i4.1328

Refbacks

  • There are currently no refbacks.


Copyright (c) 2024 Sstuti D. Mehra, Sujala D. Shetty

License URL: https://creativecommons.org/licenses/by-nc/4.0/