Financial time series predictions are a challenge due to their nonlinear and chaotic nature. In recent decades, many researchers and investors have studied methods to improve quantitative analysis. In the field of artificial intelligence, sophisticated machine learning techniques, such as deep learning showed better performance. In this paper, an automated trading system is built to predict future trends of stock index prices. Using an LSTM-based agent to learn temporal patterns in the data, the algorithm triggers automatic trades according to the historical data, technical analysis indicators, and risk management. The results demonstrate that the proposed method, called LSTM-RMODV, shows better performance when compared with other methods, including the buy-and-hold technique. The proposed method also works in bear or bull market conditions, showing a rate over net income based on invested capital of 228.94%. That is, despite the low accuracy, the algorithm is capable of generating consistent profits when all the transaction costs are considered.