How Machine Learning/AI Traders Beats Retail Traders with Example Strategy for Beginners

QuantProgram · Beginner ·📐 ML Fundamentals ·2y ago

About this lesson

In this video we will discuss how traders who use machine learning strategies will outperform the retail traders in future. We will also explain how to create a machine e learning strategy right from scratch. We have released our Machine Learning /AI course. Make use of the early bird offer. Our Course's https://www.quantprogram.com/store Full Beginner Tutorial for Tradingview Pinecript: https://youtu.be/G4ErIBbUZOc RSI Strategy Backtested Pinescript: https://youtu.be/w1ETamJ8DcE Backtesting Pullback Strategy Pinecript: https://youtu.be/F_yGjiB0bro Stan Weinstein Strategy Pinecript code: https://youtu.be/Wodr4rCWzPw Create Stop Loss Take Profit Code: https://youtu.be/yP7qWD0JElo Creating Trailing stop Loss in Tradingview Pinescript: https://youtu.be/ZWyVF0fmGMs RSI divergence V4 Pinescript code: https://youtu.be/zCfMv_FxvME Donchian Breakout Pinescript Code: https://youtu.be/7fBlpT0YHpc Inside day Strategy Pinescript Code: https://youtu.be/_-QIv0KYnSM Bullish Engulfing Strategy Pinescript Code: https://youtu.be/JMEI9zbacbA https://www.quantprogram.com/RSI_Divergence_V5

Full Transcript

in this video you're going to learn three things one why traditional traders who use charts and indicators will go obsolete two why Traders using machine learning slai will increase and succeed and number three an example on how to create a machine learning trading strategy right from the research all the way to execution including taking commissions into account now I'm not talking about value investors value investors or long-term holders of the stock always have a fundamental good Edge and buying stocks Whenever there is a market correction provided at fair value or under value is a good decision what I'm talking specifically is day traders who use charts and indicators so let's take a simple example whose codes will be discussed deeply as we go into the video so let's say there's a traditional discretion Trader see something like a pattern and he thinks okay this might give me an edge let's say it's based on like an RSI 14 period and then he decides that hey if uh the price is taking lower lows and the RSI is kind of below 30 and I'm seeing a sudden rise in the price and I think I might go long and he kind of Compares it uh to pretty much all the other uh situations in the chart and he goes like okay that's a perfect entry I've seen it a few times it worked so I'm going to deploy that now compare this to an AI or a machine learn Trader now he has a huge Edge uh forget the rsi1 14 period what he's going to do is like he's going to put in all the numbers from r SI I 2 to 25 and tell the machine learning model to find out the patterns from all these data and find the best suited as well and on top of that he is going to tell the machine to come up with an equation that give him an edge in finding a trading signal now that doesn't end there uh he's going to test this on training data and then find out the results for that and then he's going to apply this on testing data and see whether it actually works now if it works he's going to go for it otherwise um he stops right then and there now after this he's going to actually execute this I.E algo trade it so that it gets automated so he doesn't have to worry about execution he doesn't have to worry about uh let's say Panic or hesitation or greed or confidence or missing out or any of those things the execution will be done specifically as designed by the algo and it's not just one algo so this is just one training model so imagine you can create like 10 15 models all simultaneously un correlated so this is the big Edge that the machine learning a/ Quant Trader has and it's substantial as compared to a discretionary day/ swing Trader they can't even imagine doing all these stuff manually over so many amounts of strategies now you might think it's like kind of complicated like I have to do math I have to do coding it might take a long time well it's not that difficult as people think you can be up to speed in less than a week like for instance if you you don't know coding most of the resources are available free online so if you don't know coding you can check out our video on our YouTube channel Gord M trading in Python uh it's like 3 hours long so if you commit like 30 minutes a day you know you could probably finish this in less than a week and you will be proficient in Python now again if you're worried about execution on how to execute this on the broker uh how to make this automated or algo trade it don't worry about it we've got Quan connect again free video on our Channel you should be up to speed in less than uh 2 or 3 days again 30 minutes a day so now coming to the math part you don't need to memorize things you don't need to uh know how to derive the thing all you need to know is to understand what each mathematical model does uh so you can use the ideas in the right equation so in this video alone we'll be discussing two important features of machine Learning How It Was researched how we collect the data how we executed it and you will see for yourself how simple it is uh and then later on you will be able to squeeze it in your own ideas in the same way uh so let's start with what PCA or principal component analysis uh is so this is like a statistical tool so it's pretty simple let's say you uh you have like an image recognition software you're planning to create one and then you've got lots of data you've got lots of pictures and you have to figure out who's who uh so you've got data on the nose on the eyes on the eyebrows and the lips and all these things so what PCA does is it takes all these features right so imagine you've got like 25 features of the face that's a lot like you can take like cheekbones and color of the skin and uh the ears the hair and all those things so you can reduce that 20 25 features to maybe like five or six and that's what principal component does uh so it takes a huge amount of data and then it compresses to a few five or six so it might feel like hey the nose is not that significant or the eyes is not that significant eyes and eyebrow is not that significant in actually uh confirming whether the person's image recognition is correct or not um instead the lips and the nose combination might be far more efficient so you can completely ignore the eyes and eyebrows you can give them less weights or whatever uh less importance or in fact you know remove that data completely so what it basically does is that it takes out the noise right so he takes out the noise and thus helps us get improved data I.E data without noise and on top of that you also get better computational performance because you're having lots of these data right you don't you don't need to have like these too much amount of data that can create any issues so how can we use PCA for trading so just like the example that I said in the beginning you can use the same RSI numbers like RSI 2 25 so that's like 20 plus sets of data Columns of data and multiple days of rows if you're losing 10 10 years or R it's like a tremendous amount of data so what I can do is I can tell PC to say you know what I don't want the 20 plus data I want you to reduce the amount of data to maybe like five or six instead of 20 plus so PCA helps us achieve that so it takes out all the noise of that RSI and only gives us the important information from the RSI which we can use to create trading signals now once you have changed or transformed that data right the RSI data which we can do not only in RSI we can actually do it on volume we can do it on moving average uh we can do it on adx but now you can use let's say this one this RSI we've got the data we've transformed it to a lower dimensionality now we can use this data and use a machine learning model uh to actually create a signal to enter and exit so we can use like a linear regression model which comes under supervised learning uh so simple question what is supervised learning supervised learning has got two characteristics one is the input feature or label features and then the output feature which is uh something you're trying to predict so called Target variable so I know it's kind of complicated but it's not really so in this simple example it's the input features will be the RSI numbers the six numbers that we created from the BCA and the output will be the future price or return depending on what you want to predict uh so if you want to Summit up this whole trading strategy in one simple sentence uh we are using the RSI data and we using PCA to transform this data and use a supervised learning strategy supervised machine learning model model uh to create trading entries and exits and that's it that's that's how simple how the trading strategies so once we've designed this model we need to apply it on training and testing data so once we get this model we applying training data to see okay this is the best fit this works here now that does not mean anything we need to take this and we need to apply it on a testing data a data that's completely outside the data uh of the training so it could be from if you're doing the training from 2000 2010 you can do it from 20102 or maybe even a smaller uh size like maybe you can do it from 2020 to 2023 you know try to see how it works in volatile period or trending period to see how how it performs once that's done once we get the green signal from the testing data then we are ready to go then we can actually plug in our codes to uh Quan connect and then just feed in the username and password the login details for interactive brokers or any of the other accounts and that's it that's one trading strategy right there so you can do strategy similar like this maybe like 10 15 depending upon your account size the amount of opportunities that you could do uh to actually create efficient strategies is pretty cool so now let's run through this code which covers the entire process and it's amazing testing results so the entire code for the jupyter notebook and the Quan connect is available for our course students in Prometheus um it's under the code section uh now you can take these codes and make changes to it or even completely change inputs from RSI to like I said adx or uh vol volume or on balance volume okay so this is the code that is in the Jupiter notebook so initially we'll be importing the libraries and we'll be using the pyit uh learn library to do the linear regression which is supervised model and also the PCA as well and then we'll be downloading the data so initially we'll be doing it for the training data and then we'll be doing it on the testing data and as seen before we'll be downloading the RSI we'll be creating the RSI 2 period to 25 period for the Spy and then we will be calculating the principal component analysis and we'll be reducing the dimensionality as discussed before uh to six and then we'll be doing a supervised model in this specific case we'll be doing a linear regression uh linear regression is quite simple and it's quite effective in machine learning I mean there are many complex models but sometimes Simplicity works much better I'm not going to go deep into linear regression um we did a small video on linear regression before as well uh so once we get the linear regression which we'll use as a predictive uh measure so we are actually predicting the price six days ahead so you've taken the six days ahead returns as well um and then we're going to use the PCA data uh and then we're going to calculate the thresholds um so in this we' have taken the thresholds of 0.90 and 0.10 which is like the extreme end of the prediction uh So based on that threshold we can create like a signal whether to go long or whether to go short short um and then we will calculate the returns of it based on this specific strategy uh so I've created um the returns and also compared with the Spy returns so this is from 2 2010 uh so you can see the results are positive but this is not something special uh and it has outperform the spy uh because the reason why it's not special is because it's done on the training model so it's supposed to work well uh now we have to apply this on a testing data so for that we're going to do 2020 to 2023 so in Quant connect I'll do a completely different time but for here just just recent developments from 202 2023 on the spy and we're going to do the exact same RSI uh and then we're going to use whatever we used before the PTA uh data that we got we're going to use it here um and then we're also going to do the um the model that we created here the uh supervis model we're going to apply there and then we are going to end based on the signals that we created based on the thresholds uh as well and once we do that this is the final result of that so the final investment value of 10,000 um dollar invested we will get uh something around 12,612 46 um so this is the initial um analysis that we do in the jupyter notebook now we'll go to Quan connect and then we'll apply it on on Quan connect platform so we can execute the strategy live uh so in Quan connect it's not as simple as you think because again in Quan connect we have to do the exact same things we have to do a training model and also we have to do um the test on a back test model now just to interrupt a bit now if you like my training style um I am thinking of creating a course which purely focuses on uh machine learning trading strategies so so far we've been doing more of a quantitative based strategy which is quite simple uh but machine learning is slightly more complicated because there's there's math involved so um just like the PCA there are other maths involved uh just like superv model you can do things like C's clustering which can helps you with the portfolio but it is it's quite a lot of work so you need to put in lots of information in there before I make the course but I will only be making that course if you guys are quite interested in it so what I'm going to do is I'm going to give a link in the description box and in the comment section um all you have to do is just show your interest in that link by giving uh your email so if if the number of people who are interested in that purely machine learning AI trading strategy course is like more than 100 or something like that I will seriously put an effort uh in bringing that course and I'll also be giving a discount to those people who actually show the interest as well so people who bought the Prometheus score they will also be giving given a small amount of discount for their upgrade uh to the machine learning course as well now going back to the codes if you can go to the here you can you can see the advantage of of uh Quan connect is that you can actually use all these libraries the pyed libraries and then uh execute the strategy U so you just have to go and initially we have we decid 2010 to 2023 that will be our testing so I want it to be a much more a bigger testing space so you can see the actual returns uh much more better but we need to create a training window as well so for training we use here we created a training window of 2020 then we calculate the RSI values and all the other things like the PCA and the um uh linear regression model and all those things and the result we got is this uh we've taken commissions into account um so we've got $275,800 there has been a certain um years we have a slight bit of draw down here for example in 2020 um and if you can go down uh we'll go into much more detail here uh so you can see the compound annual return is 8 and the draw down is 27 which is actually much better than the uh typical SPX investment so SPX investment is on average 10% cagr uh but the draw down is like 55% so this is actually pretty good uh so the CGR to draw down ratio for this strategy is much Superior to that of the SP spy Buy and Hold but there are lots of improvements to be done we can add in other things so in this case we only used RSI as the um as a PCA we can actually use many other things uh we can use the volume we can use the adx and we can also create mess around with the um you know the thresholds and all those things and we can also do a portfolio based strategy as well apart from the um spy so there are lots of improvements to be done anyways the entire code for this strategy both in Quan connect uh and in the jupyter notebook is available for the premier students as of now so I hope you enjoy this video I hope you understood what I'm trying to convey uh it is not that complicated if you actually put in an effort and if you just go through the methodology step by step if you watch a videos in Python andan connect and if you can understand the procedures better then you are going to succeed in deploying this and in Quan connect it is quite easy you just have to go live trade and if your favorite broker is in there then it becomes much easier uh you just have to just put in the username and password we've disc this in the qu qu connect tutorial video uh anyways hope you enjoy this video thank you so much for watching bye-bye

Original Description

In this video we will discuss how traders who use machine learning strategies will outperform the retail traders in future. We will also explain how to create a machine e learning strategy right from scratch. We have released our Machine Learning /AI course. Make use of the early bird offer. Our Course's https://www.quantprogram.com/store Full Beginner Tutorial for Tradingview Pinecript: https://youtu.be/G4ErIBbUZOc RSI Strategy Backtested Pinescript: https://youtu.be/w1ETamJ8DcE Backtesting Pullback Strategy Pinecript: https://youtu.be/F_yGjiB0bro Stan Weinstein Strategy Pinecript code: https://youtu.be/Wodr4rCWzPw Create Stop Loss Take Profit Code: https://youtu.be/yP7qWD0JElo Creating Trailing stop Loss in Tradingview Pinescript: https://youtu.be/ZWyVF0fmGMs RSI divergence V4 Pinescript code: https://youtu.be/zCfMv_FxvME Donchian Breakout Pinescript Code: https://youtu.be/7fBlpT0YHpc Inside day Strategy Pinescript Code: https://youtu.be/_-QIv0KYnSM Bullish Engulfing Strategy Pinescript Code: https://youtu.be/JMEI9zbacbA https://www.quantprogram.com/RSI_Divergence_V5
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Related Reads

📰
I Didn’t Solve the Hardest Problems in Code Analysis. I Mapped Where They Begin.
Learn how a deterministic code analysis tool maps its own limits to provide more accurate results, and why this approach matters for reliable code analysis
Medium · Programming
📰
I Didn’t Solve the Hardest Problems in Code Analysis. I Mapped Where They Begin.
Learn how a code analysis tool maps its own limitations to improve performance and reliability
Medium · Python
📰
Are Your ML Experiments a Mess? Here’s the Fix
Learn to organize ML experiments with ML Flow and reproduce results efficiently
Towards Data Science
📰
From Straight Lines to Smarter Models: Understanding Regression and Regularization in Machine Learning
Learn to implement linear regression and regularization in machine learning to build smarter models
Dev.to · Kendi
Up next
SQLite3 Tutorial - Learn SQL for Python in 17 Minutes
Thomas Janssen
Watch →