File Exchange

image thumbnail

Files for webinar titled "Classifying Trading Signals using Machine Learning and Deep Learning"

version (1.44 MB) by MathWorks Quant Team
You will learn how to classify trading signals into "buy" or "sell" using machine/deep learning


Updated 12 Apr 2018

View Version History

View License

Using the stock index data, we will show how to perform:
- Data preprocessing, factor creation, and data partitioning
- Rule-based trading (Demo1)
- Classifying trading signals using Classification Learner App (Demo2)
- Classifying trading signals using LSTM (Demo3)

Cite As

MathWorks Quant Team (2021). Files for webinar titled "Classifying Trading Signals using Machine Learning and Deep Learning" (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (19)

Sinan Islam


The webinar is quite interesting and explicative. However, I have tried to reproduce it on my PC with these files but there are some missing. How can I get the "data3_demo2.mat" and "data3_demo3.mat" files?
Thank you in advance,

juan nadal


I have a question regarding the standardisation in data3_Partitioning. (xInSample = (xInSample- repmat(muTrain,nIn,1)) ./ repmat(muTrain,nIn,1);) and the equivalent for the out of sample period.
It should be divided by sigmaTrain, no?



MathWorks Quant Team

Hi Giovanni,

What you describe in the comment is a combination of rule-based trading. I think you can use machine / deep learning to generate signal using 7 days returns (as a response variable). But, you may need to back-test with your rules on holding period later. The latter must be done on a back-testing framework.


Giovanni Barbarossa

Hello Kawee,
I really enjoyed the submission.
I tried with no much success to modify the program to generate a response variable that, assuming that we could buy at the end of the trading period when the signal is generated, is a Buy if the returns>0 at the end of any of the next N trading periods, and it is a Sell if the returns<0 at the end of any of the next N trading periods, where N=7 for example. In the demo provided N=1 and I am trying to generalize it. Would you be able to help?

Giovanni Barbarossa

Thanks Kawee. There is a solution, but probably too much work...change the end date from Dec.31 2017 to today and re run the demo script! Thanks anyway.

MathWorks Quant Team

Hi Giovanni,
Unfortunately, your request is something that I am not allowed to do.

Giovanni Barbarossa

Hello Kawee,
really great demo. In order to reproduce the results, it would be great if you could upload the original data1.mat file because fred does not go back now to Feb.29, 2008 which was available at the time of the webinar and it was 3652 days before the end date of Dec.31, 2017 in the demo. It only goes back to Apr.30, 2009.


Re: Antonio Alvarez....I suggest re-running without the normalization in the Partition. Good Luck



MathWorks Quant Team

Sorry for the delated answer. I've just seen the question. You can get the training data by running the following files, respectively.
1. data1_Retrieving.mlx
2. data2_Preprocessing.mlx
3. data3_Partitioning.mlx

Ruvita Faurina

hi, can you also include the data training ?

MathWorks Quant Team

Hi Antonio,

First of all, the demos are mainly designed to show how to create simple models. Although you have used open, high, low, and close, these 4 variables are originally derived from the price. In short, it's not easy to build a good predictive model from price data alone. Data plays a very important role in modeling.


Antonio Alvarez

I forgot to say that I'm using month, day of the month, day of the week, hour, open, high, low and close 1 minute values as input data. It's a total of, more or less, 4,500,000 x 8 values for training.

Antonio Alvarez

I have been trying to train an LSTM network. I'm using last ten years of EUR/USD data and I get results similar to yours, with a 50% accuracy, that is the same that classify randomly.
I've tried adam and sgdm, with learning rates from 1 to 1d-9. I'm normalizing the data, randomizing it and using the same amount of "buy" and "sell" training responses, I've also tried with different batch sizes and number of layers and cell units.
I'm starting to think that it's not possible to train a network with a good accuracy, but since this is the first LSTM network I train, I don't know if I'm doing something wrong.

Have you been able to achieve a good precision?

ye shan

ok. solved it. I should run data1_Retrieving at first

MathWorks Quant Team

Hi Nick,

The webinar is not available yet. This code is for a future webinar(Apr 2018),



Can you provide a link to the webinar? I can't find it

MATLAB Release Compatibility
Created with R2017b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!