ChatGPT Trading Strategies for NIFTY 50

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone and welcome to my YouTube channel today I'm going to use chat GPT to build 10 trading strategies using pinescript to trade Nifty for each of those 10 strategies I'm going to do the back testing based on historical data in the trading view to see which of those trading strategies is the most profitable so let's start first of all let's go to the Chart GPT and ask to give us ideas for 10 strategies which can be profitable to trade Nifty and which we can build based on the point script so let's execute and let's see what will be the outcome so as you can see charge GPT straight away giving us 10 strategies which are moving average crossover Trend following error PSI macd Fibonacci breakout so all of those are quite standard strategies and I think they could be profitable so let's try them all and let's see which of them is the most profitable so let's ask to get the pine script for the first strategy which is moving average crossover and let's test it so here we are we are getting Pine script for the crossover strategy it is using uh fast and slow moving averages if you don't know about like moving average indicators please check this video on my Channel with very detailed tutorial about moving averages all top five moving averages are explained in all details so let's ask to change uh the to using the strategy because it's using the study and we also ask him to change the library because we should use the TA Library which is technical analysis Library so we sometimes have to educate the charge BT because she probably don't know everything and but we we can teach her how to use some of the functions in a pine script okay so we are getting the final code now so as you can see it's using again SMA so we also asked to add the plot so we have our plotting for the fast and slow Ma so we'll have a graphs and let's let's see now let's copy and let's go to the trading View okay we don't need this now let's change it to the Nifty okay okay now we need to go to the Pine script editor let's remove everything here just leave the version 5 because that's important line now let's save it and I think we need to change the library here as well you see it's it still didn't change it we need to put T8 dot SMA and ta dot SMA right okay so what else again and crossovers also doesn't using the TA okay so you see those mistakes we need to change and correct by ourselves okay so let's save it and let's add to the chart and we're getting back testing results straight away let's see and we have 120 percent which is not bad for the first strategy which is just a simple moving average crossover strategy and we can see how it's working right so we have uh slow SMA which is uh red line and we have fast SMA which is Blue Line and when the Blue Line crosses Red Line from like from below and that's that's the signal for buy for buying the asset right for buying the Nifty and when the blue line is crossing the red line from above which happened some way here yeah here we are selling so here we bought we're keeping it and here we sold and here we have like the the waves which went up and down so there was some false uh crossover so it this this strategy is very simple right so it doesn't it doesn't eliminating this kind of situations but even even though it gives us 120 okay which is not bad for the beginning um so we also can see all the trades so we started here with five thousand and we finished with 17 000. okay that's the result of the first strategy and that's how it's working and now let's just record the result just not to forget let's use Rapid tables and let's put our results of the trading strategy which called moving average crossover what was the result it was it was 120 right let's let's use it let's copy it here copy paste here okay so we have first result 120.95 that was the outcome and now let's ask chargpt to create a trading strategy for second strategy which is malinga band and while it charge apt creating a trading strategy let's just do the small introduction what's the Bollinger brand is about so balinga bands is a technical indicator that the measure Market volatility by plotting two lines uh for two standard deviations away from the moving average the balinga balance helped identify when prices are oversold or overbought okay now we have a strategy for in the pine script let's just copy it and let's go back to our trading View so let's go to the point script editor let's create new indicator let's close this we don't need this and let's just remove the previous one remove the this from the editor copy paste and you see again we need to do some corrections let's save first and change the cross above there is no such cross above there is only cross over and cross under in a pine script version 5. so it should be cross over okay and that should be okay I think right let's save it and let's add to the chart okay so here we are we have how much 73 percent profitability which is not that bad but not as good as the previous one as what we can see we have two lines right as the balinga bands is working we have like upper line and uh the bottom line and the price is going between so as soon as it's reaching the lower band we are going into the long position so we're buying and as soon as it's touching the top level of this band we are selling so the very simple here we we bought you see and then here we sold and then again it touched the below bottom and here we sold when it touched the upper band but sometimes it giving a false results you see this situation when we bought and we sold on the lower level so you can't just use those trading strategies by themselves you have to use the risk management and put a stop loss levels in your trading strategies but here we just testing the the basic strategies right those could be our fundamental things which we can adjust and improve later on okay now we have 73 percent for this uh strategy let's put it down here so it was balinga bands uh strategy so we we can't copy it here let's just probably okay copy it here fine and let's put it in our records spreadsheet and now let's go to the chat GPT and ask to create the third strategy so the third strategy was RSI Divergent strategy and we are getting the pine script so which is using uh ta RSI for the two weeks and making the plot and again you see it's again using the crossover and cross under without CA Library so let's copy paste it here uh put additionally ta dot crossover CA cross under and this one I don't think it will work because like we already crossing over RSI above 50 so it can't be less 50. so let's remove the overlay let's add you see it doesn't work so let's go back and let's do some editing uh let's do the RSI level of over sold about 30. and overboard about 65 maybe right and let's remove those things and the rest should be okay so yeah let's put 40 I think it will be easier for us yeah some way here it will be yeah because that that will be the level let's put it 40 and you see the the the profitability is going on on the level of 111. so eres PSI divisions giving us 111 percent which is not bad right good and now let's go back to our charge PT and ask to create the next trading strategy please give my script for uh Trend following strategy and let's wait what will be the outcome Trend falling it's quite simple strategy as well we're using sma50 as a our Baseline and when we're crossing over then we are buying when we're crossing under then we're selling so let's uh let's try let's create one more indicator let's copy paste and we need to change again put the lip here should be okay now let's just save it and put it on the chart okay yeah here we are and let's see that wow 217 percent that's the best so far 217 percent profitability straight away without any changes uh without any customization 217 percent which is the best so far and uh you can see how the trading strategy is working right so when we're touching the when we're crossing under the trend line which is a slow SMA we are going into long and when we're crossing it over uh Crossing it under again so from the above right we're going from above uh Crossing it then we are selling it's working fine but then sometimes we're having this kind of situation when the price is going doing back around the trend line that's where we're losing the money but anyway uh even without elimination of those kind of situation it's 217 so we can tune it a bit and it should be much better so 217 straight away that's not a bad profitability in my perspective okay now let's go and do the next strategy which is macd strategy so macd is the technical analysis indicator which is let's copy that uh and let's see how it will how it will show on the trend and I will explain it based on that let's copy paste here we need to yeah macd and it's highlighted by Red because it's like they're using the charge GPT using old version of the pine script in the fifth version of the pine script that should be a right with the three elements so let's just change it so we need to have a macd signal line and one more one more variable so let's just let's just have a three lines magazine line signal line and histogram line right so let's update the rest of the variables in the in the quad and put it on the chart okay we're having 177 percent that's the profitability okay and let's now let me show how it's working right so first of all let's remove it from the overlay let's put it false then we'll have a separate trend line we need to remove everything and let's put it again so again you see is that's how it's working we have we have macd line and we have signal line the macd line is the red and uh blue is a signal line so when the signal line is crossing red line that's the Buy Signal when it's Crossing uh from above then it's a cell signal and that's what you can see here we're buying and here we are selling right so when we're crossing over we are buying Crossing above we are selling and 177 percent not bad so each of those strategies by themselves separately showing quite a good results in my perspective so we definitely need to see and find the options how we can combine them right and how to eliminate those situations when we're losing some trades so but that's kind of big different story by itself but as of today which is quite good now we're doing uh next trading strategy which is Fibonacci which is Fibonacci retracement so uh how Fibonacci levels are working so Fibonacci is like a golden standard thing so um it's defined it defined levels so let me show you later on the on the trading view so let's remove everything and let's uh create one more indicator and let's put the code which child GPT gave us let's save it you see the charge GPT using ta Fibonacci that's not there is no such thing in uh as you can see there is no such thing in the trading view you have it in a python in the python library for technical analysis you do have it but in in uh in a pine script there is no such thing as a Fibonacci function so that's why let's create those Levels by ourselves so usually in a trading we're using a few like only a few levels of the Fibonacci first one is zero six one eight it's just like golden numbers and uh for as a kind of Buy Signal and like over overboard oversold level and another one is 0.382 as a oversold level so when we're crossing the 0.3 we are buying with uh so means we are selling and then when we're crossing 0.6 we are buying right it's again levels around the price action this one we're just changing to our buy level and we're changing this to the sale level so we just kind of customize not customizing but we are rewriting the code using the same logic but we're just rewriting it how it should be done because it looks like child GPT not really aware about all latest development in a pine script version 5 and she doesn't know how all functions are working so sometimes she's messing up okay so the profitability is 170 and you see those kind of Fibonacci lines when we're crossing the purple line a pink line we are buying and when we're crossing the Orange Line we are selling but uh you see it's not really much profitable here but that's quite you see the the trades happening quite uh like rarely but they are mostly profitable so which means like that's quite a strong signal right so we we're making 170 percent so let's let's put it in our records and let's probably go to the seventh trading strategy which will be the breakout strategy okay let's now check how the child GPT will create breakout strategy for us so let's ask please give a script for the breakout strategy and let's see what will be the outcome probably there will be some mistakes again but yeah I will fix them no problem okay um again yes I see that it's using the channel Library which is not a pine script function looks like we will need to rewrite it again um yeah so the channels the channels is the Divergence uh band again using the highest and the lowest levels for the sum period of time in the past so let me show you how to rewrite that so let's remove this paste it here and this function it will not work so because it's not exist in the pine script but let's just create it by ourselves so we need to have two lines the first one is channel let's call it Channel up probably and it should be the level which is equal to the highest price highest close price for the last uh 20 days as it was given by child gbt she wants us to use 20 days last 20 days and with the with a slight uh look back for the 10 uh for the 10 days right so it means we are not checking the yesterday's price but we're checking like 20 days from 10 days from today right I I hope I managed to explain so we're taking the highest price from for the 10 days which will for the 20 days which were 10 days from today and the same for the lowest so and then we are getting two two lines and which creating a channel and now let's use them for plotting let's create one more plot so it will be our Channel up and we will create one more Channel bottom it kind of saving the lowest and saving the highest price right it's like a log for the last highest and the lowest prices it's it it is kind of balinga band thing but without Divergence it's more like just a high price which is which is also having uh some benefits this trading this indicator but by the way it's used quite often for the risk management so it could be your stop-loss signal at the bottom but we will talk about it in a separate video so yeah let's let's put it on the chart and we're getting 81 81 profitability right so reaching surprising every strategy which we're testing is showing the positive results so we are on the seventh or sixth uh training strategy right now and we're still profitable sometimes even 200 profitability which is surprisingly good okay and you see that's that's how it's working right so we we're keeping the price and let's just do some optimization maybe it will be better results I I think uh let's put uh five days look back yeah when you see the profitability is increasing to 127 and let's change it to one day look back let's see if the profitability will be better yeah it's even better 165 percent okay so yeah there's no much reason to having 10 days look back but I think one day look back is it is it is a standard look back uh option and I think we will use that and it's giving the reasonable profitability okay now let's go to the next one the next one was uh Candlestick patterns that could be quite a tricky one but let's try let's ask chargpt to create a Candlestick patterns there are multiple Candlestick patterns I'm not sure which one the charge GPT will give us but we will try at least I will show you the the way how it's working right and then we can customize the Candlestick patterns to the different Candlestick patterns and we can compare which of those working better but that's for the testing purpose we'll see is it working or not working at all and is is it have any reason for us to spend our time right and let's see uh you see again it's using ta dot cdl3 white soldiers yeah that was again those are a python Library so as you can see uh charge gbt mixing up the pine script and python all in one place um don't know why she's doing that but that's how it's working right so you can't be 100 like sure about the results right you have you have to know what you're doing you have to note uh the program Language by yourself to be able to customize and correct the things Okay so I think we will just again well I'm asking her to change it uh from the python library to just using closing and open prices but she's just giving something wrong I think I'll just yeah let's just ask to use uh Candlestick button and just close and open prices yeah finally she understood so she's not using any fancy libraries she's just using uh very straight way of doing things by comparing close and open prices here's a formula for bullish and bearish yeah so those are comparing when the when the bar charts when the price enclosed and open price uh fits to the pattern and yeah that's how it's it's so many so many trades happening yeah that's so many candle patterns happened in the so I don't think this candle patterns is really fits to this Market I think we need to do um more research for which kind of candle patterns we can use for that and as you can see just giving 27 profitability but still profitability which is surprising right okay let's just put records I don't think the Candlestick pattern is fits to this kind of Highly volatile Market but let's see I think we need to do more research for the candlesticks in how much it can be used for Nifty I I don't think so so let's go and check the volume Spike level that should be straightforward strategy I don't think it will bring any profitability because just the volume itself it's not the proper way of uh defining biocell signals yeah let's just let's try let's try at least I will show you how it's working and you can customize it or you can play with that improve it somehow but at least or you can use it for your trading strategies but you at least you will know that such thing is existing in in a prime script so for the threshold let's use uh average uh simple moving average for the volume and let's put it in on a separate chart let's save it and let's put a plot let's put a plot for the volume and for the for the signal put it on in the red color and let's create one more plot for the threshold just yeah let's create one yellow and one one red okay this one is just changed to the threshold okay save save when volume is above threshold we are buying and when the volume is not above the threshold we are not buying and it's just 3.6 as you can see yeah so you see when the red line is when the yellow line crosses the red line then we are buying and then we are selling on the second uh bar chart straight after that just reduce the threshold we will buy more much more frequently and let's put the volume indicator just to see if it working well yeah so you see if the volume is have a spike and if it's above of an average that's a signal for us we are buying and then it's more like a momentum momentum indicator so for example if there is big big buyer and he's trying to buy then we're trying to follow but as you can see sometimes it's going to the opposite direction sometimes it's it's not a green bar sometimes it's just a red bar so it's no reason to go into the long position right but we can customize it later anyway we're testing how much charge GPT can give the trading strategy and how much they can be profitable straight away or at least using the same logic which she gave us but as of now for the volume just 15 so not good at all now let's test our last trading strategy which was which was um mean reversion yeah um that's that's the same kind of crossover strategy based on the uh SMA but let's see I don't think it will give any any any profit but at least we will have any unprofitable strategy I think that would be good for just for comparison right okay let's get the pine script yeah you see we're using SMA again for the based on the closing price for the last 20 days and when close price below ma we are buying when close price going below ma we are selling I mean it's very it it's I would say it's even a bit stupid strategy I would not use it at all but but let's try let's try just for experiment and let's see what will be the outcome so uh just remove everything here let's paste our code we need to change again I don't know why she's keeping keep giving the wrong code uh okay save and let's put it on the chart yeah yeah as I said it is just random random buy and sell signals yeah and as you can see there is no no profitability at all just just just random just random buying and selling yeah but that's the result uh not all the result could be positive some results are negative which is good and but that's the result and that's how was our 10th trading strategy with 3.8 percent and so our winner is Trend following this is the best trading strategy which uh GPT created for us for Nifty and let's look at this once again so where was Trend falling yeah that was quite a good strategy straight away without any changes that's how it it gave us uh very straightforward uh and is what we can see 270 percent straight from the chat GPT without any changes so I think this video was useful for you guys and girls uh please comment if you have any questions or some ideas or you didn't understand anything or something I'll put all the chords uh on my Gamma Road and we'll put Link in the description then you can try that everything by yourself but as of now thank you very much for your time hit the like button And subscribe to the channel and see you in the next video bye bye
Info
Channel: QuantTrader
Views: 7,381
Rating: undefined out of 5
Keywords: ChatGPT, Chat GPT, NIFTY, NIFTY 50, NIFTY Bank, Trading Strategies, Moving Average Crossover, RSI Divergence, Trend Following, MACD Crossover, Fibonacci Retracements, Breakout, Candlestick Patterns, Volume Spike, Mean Reversion, Bollinger Bands, PineScript v5, technical analysis, stock market, trading, finance, investing, stock trading, algorithmic trading, investment strategy, day trading, options trading
Id: SDOLjEJlnow
Channel Id: undefined
Length: 30min 35sec (1835 seconds)
Published: Fri Feb 03 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.