AI for stock market charts pattern recognition

Hello, I am trying to create an AI solution to identify stock market patterns. What I want to identify is a trend change.
The goal of this project is not to make money, but to have AI way to perform data analisis and backtesting.
I have many training examples. A training example consists of a secuence of timeline entries, where each entry consists of a few decimal values (open /close/high/low price, a couple of statistical indicators).
Does anyone have an idea about how to start with this project? Or if there is any existing toolset/libraries I could use to start with this?
Thanks

What machine learning courses have you attended?

I took the Deep Learning Specialization a few months ago.

It is outside the scope of the courses here, and I haven’t played with it yet, but you might check out Prophet: Prophet | Forecasting at scale.

DLS Course 5 covers sequence models - that’s how you can handle time sequence events.

What exactly do you mean by “identify stock market patterns”? In what form do you want these events reported to the user?

1 Like

And yes, @TMosh, is correct, but they were asking for a ‘library’, so I was trying to think.

Some trading market professionals identify a trend change by using 2 Sma (simple moving average) indicators: one of short period (for example one week) and another of long period ( for example 2 months). When the Sma of short period crosses the sma of long period and the crossing directon is up it is said that it is a trend change and that the direcction is up. In some cases this theory works but in other cases it fails. So I would like to identify the probability of sucess when Sma indicators crosses in the future. I would like to have something like: this trend change has a high probability of being true or false. Just that.

Nice to know. I will take a look

One idea (financial markets are not my area of skill):

You could pre-compute these indicators for each example.
The market data are the features - the indicator values are the labels.

Then you design a sequence model to predict these indicators based on the market data.

1 Like

@Hector_Gonzalez
Keep in mind 2 main concepts.

  1. Billions of dollars and countless of highly paid Machine learning specialists, armed with massive computing power, are already employed by huge hedge funds to chase those quantitative signals and monetize them before you do. So, be aware that you’re going to a fight armed with a stick, against a modern army with tanks. Not impossible, :), but keep that in mind in your plans.
  2. Algorithms are statistical, and therefore you only get close to the theoretical or observed expected value with a very large sample, (law of large numbers). In other words, if you develop an algorithm with an edge or a signal, that you hope to monetize, it is still a probabilistic decision. The first trade, or a few trades you place based on your signal, may not reflect the actual long term result. So, to actualize those gains, you will need to place a large number of trades, to build a large enough sample to reach the expected value of your statistical approach. That’s why those massive funds can do it. They can place thousands of trades, worth millions of dollars, to try to get the results their algorithms showed that they can achieve.

Good luck. !

3 Likes

To start your AI project for identifying stock market trend changes, begin by clearly defining your problem and preparing your data, including cleaning and feature engineering. For modeling, consider using Recurrent Neural Networks (RNNs), especially Long Short-Term Memory (LSTM) networks, which are well-suited for sequential data. Utilize Python libraries like TensorFlow/Keras or PyTorch for building your model, and incorporate backtesting tools such as Backtrader or QuantConnect to evaluate your model’s performance. Ensure you regularly update and monitor your model with new data to maintain accuracy and relevance.

1 Like

I understand. But I am not going to use this AI solution to make money. I want to have an AI tool that helps me identify the probability of a trend change (based on Moving Average Crossover strategy) to be real. So at the end I will have an output that tells me if it a trend change or not. I have been some backtesting in Trading View with PineScript, but I would like to have an AI way to analize the data :slight_smile:

Thanks for the idea. But what if I use all the statistical indicators and the market data as features, and the labels are true or false indicating if it the trend change happened in the next N days. Could I use this binary classification approach?

@Hector_Gonzalez, it depends on what sort of output you will find useful.

I don’t have any direct experience in this area, so I’m going to just monitor the discussion and see if I can get smarter.

Well, stock market is more than just data as it includes complex sentiment analysis and FED policies. However, if you’re only doing it for research purposes, the first thing you’ll need is a huge amount of data, both training and validation. If you just want to classify an uptrend or downtrend you can use Random Forest or Decision Trees. If you need more complex prediction for Time-series data use LSTM or GRU with Isolation Forest for anomaly detection. You can further enhance it by using Reinforcement Learning at each epoch.

I have done a similar task using LSTM-CNN and extended part including Reinforcement Learning, if need be, I can share the GitHub link for your reference.

Thanks for the information. It is true that stock markets are complex, but charts reflect the market status no matter how good or bad news are. I have been doing a lot of manual analysis of charts and would like to do the exercise of doing the same using AI.
I will start with uptrend/downtrend classification.

I would really appreciate that

rohannchauhann/Stock-Price-Prediction: Stock Price Prediction using LSTM-CNN (github.com)
Instead of predicting uptrend/downtrend I simply used a LSTM and CNN approach to predict the chart pattern. There is an extended part with RL that you can find in my repository.
Hope this helps!!

Thanks, it looks amazing. You did a great job

1 Like