Intraday Trading Strategy in Python [Trend following] incl. 1 month Backtest

  Рет қаралды 27,632

Algovibes

Algovibes

Күн бұрын

Пікірлер: 94
@Algovibes
@Algovibes 3 жыл бұрын
Hi everyone, thanks for watching. if you want to see how those kind of strategies can be implemented in live real money trading be kindly invited to check out my video: kzbin.info/www/bejne/qJTCimmomaekjq8
@kyle_bro
@kyle_bro 3 жыл бұрын
I had to stop everything I was doing to watch this because I already know it's going to be awesome
@Algovibes
@Algovibes 3 жыл бұрын
What a legendary comment :-D Thanks for that and also thanks everyone liking the comment. Really appreciate it.
@Asparuh.Emilov
@Asparuh.Emilov Жыл бұрын
I love your videos! You are so explicit, so accurate and very much comprehensive! Totally learning a lot from you bro! Thank you so much! ♥️♥️♥️
@Algovibes
@Algovibes Жыл бұрын
Really appreciate your comment and your positive attitude. Thank you so much!
@PavelSumik
@PavelSumik 3 жыл бұрын
absolutely great work , you are better and better, thx much, I am very interested in these trading techniques and backtesting
@Algovibes
@Algovibes 3 жыл бұрын
Thank you so much :-)
@haidar901
@haidar901 3 жыл бұрын
Thank you very much, I hope more to come ! All Love and stay safe
@Algovibes
@Algovibes 3 жыл бұрын
Thank YOU for watching and your kind words. Love ❤️ back and you stay safe as well please!
@User66866
@User66866 3 жыл бұрын
Like intraday strategy videos a lot! Thank you for sharing!
@Algovibes
@Algovibes 3 жыл бұрын
Thank YOU for watching and commenting :-)
@jitkadyan
@jitkadyan 3 жыл бұрын
Superb video again
@Algovibes
@Algovibes 3 жыл бұрын
Thank you very much :-)
@Anzeljaeg
@Anzeljaeg 2 жыл бұрын
Anohet thank commen , dude you rock
@rraul
@rraul 3 жыл бұрын
You are awesome, man! Thanks. Based on your momentum video i have finded a great strategy to profit in brazilian market.
@Algovibes
@Algovibes 3 жыл бұрын
No, u are for supporting me :-) That's really great to hear! Thank you very much for watching.
@sz8558
@sz8558 3 жыл бұрын
Excellent tutorial as usual...Would be awesome to see such a strategy run for say 4weeks, and to see and analyse the daily performance with something like the pyfolio package.
@HimanshuSharma-bz2gh
@HimanshuSharma-bz2gh 3 жыл бұрын
Duuuuuuude! Awesome job! Keep it up!!
@Algovibes
@Algovibes 3 жыл бұрын
Thanks a lot buddy. Appreciate your kind words :-)
@durgeshsinghkushwaha6815
@durgeshsinghkushwaha6815 3 жыл бұрын
Master of algo trading..
@Algovibes
@Algovibes 3 жыл бұрын
Far away from that but I am working on it 😛 Thanks for your comment tho, appreciate it :-)
@amanchaure5584
@amanchaure5584 Жыл бұрын
I have back-tested this code with the intraday data of 30+ indian stocks for the last 8 years and these are the results, On an average the strategy works well till 2017, The strategy has a 8 to 10% engagement rate per year, the returns are 5 to 6%.. which is really very good. (No. of trading days are 15 to 20 only, per year). So the capital is engaged for a very less time during any given year and the returns are 5 to 6%. But after 2017.., The strategy doesn't perform well. The overall returns in most of the cases are negative.. (-6 to -8%) This is a living proof of the fact that you can't rely on a very few strategies for eternity. Sooner or later, a lot of people will try to trade them in a very similar fashion, which will lead to mean reversion of the strategy returns.
@ivang4678
@ivang4678 3 жыл бұрын
I'm trying to learn Python for backtesting strats and although this is a bit advanced for my level right now (I started from 0 a few weeks ago), it's explained in an extremely clear and eloquent fashion. Would you recommend any other material on this exact topic? Thanks and keep up the amazing work!
@Algovibes
@Algovibes 3 жыл бұрын
Hi, thanks a lot for your comment! I personally learned a lot through university/internships but can also recommend Sentdex - a KZbin legend with incredible resources on his channel.
@ne2ve2
@ne2ve2 3 жыл бұрын
Well, you can learn Python from different sources. I've learned its basics from Coursera and Datacamp. It won't be enough by itself though, you should practice everything you've learned in different scenarios be it a web scraping program that crawls through a huge website or simple pandas dataframe analytics. You could also practice R for a bit, it has a similar to pandas behavior. If you're just starting coding, language shouldn't be that much of a difficulty, on the other hand your problem solving skill would be put to a real test. Btw you probably shouldn't even touch other people's code until you have a firm understanding of what's going on.
@russskinner5715
@russskinner5715 3 жыл бұрын
Another excellent video.
@Algovibes
@Algovibes 3 жыл бұрын
Thank you so much! 😊
@juuttuub
@juuttuub 3 жыл бұрын
This is great. Could you show in some videos, how to iterate and find solid entry and exit values and show the statistics?
@Algovibes
@Algovibes 3 жыл бұрын
Thanks a lot for watching and your comment :-) Appreciate it. I will see what I can do! Thanks a bunch for the suggestion. Always helps me!
@assafcohen3173
@assafcohen3173 2 жыл бұрын
Hi, this is great and thank you for creating this video. The main thing that is missing for me here is how to implement this so it runs in real time? right now we're just looking back and checking "what if...", but how would you go about making this live?
@Algovibes
@Algovibes 2 жыл бұрын
Hi mate, Among others I am using these strategies in my cryptobots in live trading. Be invited to check out the cryptobot playlist.
@hsider
@hsider 3 жыл бұрын
Amazing work dude. The strategy gives me tiny results since it doesn't account for the down trend.
@Algovibes
@Algovibes 3 жыл бұрын
Thanks a lot for your appreciative comment. Yes you are absolutely right! One should account for that. I am actually applying a similar strategy in one of my crypto videos where I am accounting for counter movements. Be kindly invited to check that out and let me know what you think: kzbin.info/www/bejne/qJTCimmomaekjq8
@hsider
@hsider 3 жыл бұрын
@@AlgovibesI will definitely see it, I've already checked a bunch of your videos. I wanted to add that, yahoo finance has new limits on data windows, your trick didn't work and may be will never do.
@RafeedChowdhury
@RafeedChowdhury 3 жыл бұрын
Great video as usual! This code is good for backtesting. Can you make a video about london breakout trading strategy?
@Algovibes
@Algovibes 3 жыл бұрын
Awesome suggestion. Noted that. Thank you very much for watching! :-)
@fx2gbg596
@fx2gbg596 Жыл бұрын
can you also test the opening range breakout strat in python
@Algovibes
@Algovibes Жыл бұрын
Thanks for the suggestion man!
@jitkadyan
@jitkadyan 3 жыл бұрын
sir create a video of creating scanner using Talib technical indicator liabrary, how we get result faster from getting live data from api.
@Algovibes
@Algovibes 3 жыл бұрын
Awesome suggestion! Thank you very much :-)
@aravindakshans6998
@aravindakshans6998 3 жыл бұрын
it would be great if you could put up a multi time Frame intraday strategy
@Algovibes
@Algovibes 3 жыл бұрын
Thanks for the suggestion! :-) Really appreciate it and would be indeed quite interesting.
@lhsok
@lhsok 2 жыл бұрын
Great video. I got a problem executing the code. My code is stuck at cumulated [buytime:], the notification suggests the timestamp cant be calculated with the numerical operator. can anyone help me out?
@Algovibes
@Algovibes 2 жыл бұрын
Hi man, thanks a lot. did you somewhere deviate from my code? If not can you provide me a timestamp where you are struggling?
@manishagarwal8737
@manishagarwal8737 3 жыл бұрын
Really Amazing ! Can you guide us how we can use this in the live market. Do we just need to update the dates ? I mean I want a BUY or SELL signal based on the parameters I have defined in the real time market. How can I do that? Thanks in advance!
@Algovibes
@Algovibes 3 жыл бұрын
Thank you very much for watching and your comment. Appreciate it :-) I recently uploaded a video where I am doing that with cryptocurrencies using live data and store that in a SQL database. Be kindly invited to check that out: kzbin.info/www/bejne/qJTCimmomaekjq8 There will be videos on live trading stocks as well in the future. Before that I will do some technical analysis with cryptos using real time data.
@manishagarwal8737
@manishagarwal8737 3 жыл бұрын
@@Algovibes can you share your email id please ?
@Algovibes
@Algovibes 3 жыл бұрын
@@manishagarwal8737 I will in the upcoming weeks in the about page on my channel. Thanks for your patience.
@QuanttradingVega
@QuanttradingVega 3 жыл бұрын
Hey brother i have been checking your channel since past few days , can you please tell me from where should i start learning python programming .
@Algovibes
@Algovibes 3 жыл бұрын
Hi mate, very glad to have you onboard! :-) You are kindly invited to check out my Python Introduction playlist if you like. In general there are a lot of beginner tutorials here on KZbin - number one for me personally is Sentdex. I personally learned the basics in university - so I have no good first hand reference. For starting out I can also recommend DataCamp.
@QuanttradingVega
@QuanttradingVega 3 жыл бұрын
@@Algovibes okay thanks man
@jackgisel3211
@jackgisel3211 3 жыл бұрын
Could you show us how to work with real time data? I am confused how to take the code from these videos and apply them to live trading data from a WebSocket
@Algovibes
@Algovibes 3 жыл бұрын
First of all thanks a lot for watching and your question! You are absolutely right. The videos are field tests and the main objective is to construct and backtest trading ideas with the help of (python) programming. Nevertheless I am happy to announce going live with a trading strategy will be covered in this channel within this year. Thanks for your patience.
@SP-db6sh
@SP-db6sh 3 жыл бұрын
Next topic can be, Process to build & optimize a swing trading strategy through FinRL platform for implemention of DRL on trading.
@Algovibes
@Algovibes 3 жыл бұрын
Well I actually planned to do a tutorial on solving the Riemann Hypothesis beforehand and after that tell James Simons on how he should improve his portfolio structure ;-) No my friend, I am just kidding. (Deep) Reinforcement learning will not be covered at least in the near future. To give you realistic expectations - topics on my list are among others: - Implementation of trading strategies in Python (and maybe R) like initial move reversal, momentum in the Indian stock market, stock recommender system (based on technical indicators) and so on but ALSO some DL stuff like LSTM. - basic tutorials in R / Python / SQL / Pandas / Numpy / Sklearn / Julia - (basic) machine learning tutorials - some cryptocurrency trading stuff - Things I find interesting - Deployment stuff and actually going live with some trading strategies with real money - Stocks in general / stock market analysis in Python NEVERTHELESS thank you so much for sharing FinRL. I never heard it before and it is an absolutely incredible library from what I have just read. I will definitely have a closer look to that! Always be kindly invited to make suggestions. I didn't mean to turn you down, just want to give you realistic expectations. I am very thankful for your suggestions so far :-) A lot of text but I found this important to clarify. Best regards
@SP-db6sh
@SP-db6sh 3 жыл бұрын
@@Algovibes Can you mention someone working on DRL implementation on trading perspective ?
@Algovibes
@Algovibes 3 жыл бұрын
@@SP-db6sh Unfortunately not on trading but the channel 'Machine Learning with Phil' has great content on Deep Q Learning. He also has courses and seems like a nice guy. Can recommend him definitely!
@KonguNaadu
@KonguNaadu Жыл бұрын
Could you give a python code for my strategy for fee ?
@Algovibes
@Algovibes Жыл бұрын
No but you can send me the strategy per mail and if it is interesting enough I am happy to cover it in one of my future videos.
@cbritton27
@cbritton27 3 жыл бұрын
I had issues with this line: exit_price = df.loc[exit_time + dt.timedelta(minutes=1)].Open For PENN on March 1, there is no next 1 minute time interval, so I was getting a indexer error. Not sure why yf was missing this data. Either have to search for the next available interval or use the close of the current bar.
@Algovibes
@Algovibes 3 жыл бұрын
Are you really sure? I just tested it and there is data for March 1st. I had to take 5 minute intervals as first march is now too far in the past for the 1 minute intervals. But yes as you already suggested one could also just take the next row. Might be even better. Thanks a lot for sharing!
@cbritton27
@cbritton27 3 жыл бұрын
@@Algovibes Yes, it happened for several tickers, not just PENN. But then, this is yahoo finance, so not the most reliable data source.
@markk4203
@markk4203 3 жыл бұрын
@@Algovibes ​ Are 5m and longer intraday intervals available on yf more than one month back?
@Simone-vd1ps
@Simone-vd1ps 26 күн бұрын
Is it possible to backtest intraday data older than 60 days in python?
@Algovibes
@Algovibes 20 күн бұрын
Yes it is! I am showing in some video how you can do that with database storage.
@Simone-vd1ps
@Simone-vd1ps 17 күн бұрын
@@Algovibes Do you mind telling me which video in particular? Thanks for your response.
@jitkadyan
@jitkadyan 3 жыл бұрын
sir can we use sqlite in this scanner for fast getting results.
@Algovibes
@Algovibes 3 жыл бұрын
Yes sure. If you are scanning a huge amount of assets I would even recommend a more efficient solution than scraping.
@markk4203
@markk4203 3 жыл бұрын
@@Algovibes This may or may not be related but I'm going to ask here. I'm still confused as to where/when use of a database can expedite the backtesting process. I'm looking to get roughly 20 years of EOD data and then use that to study for the next year or so. I don't need to update it or maintain it after I get it. What's the difference between reading those daily .csv files in vs. creating a database after which I would then--have to import the database to dataframes? Read the database directly without need for dataframes? I don't know. And--if the database route is best with regard to speed, then can you explain how that is accomplished? Thanks!
@meetshah4800
@meetshah4800 2 жыл бұрын
How to backtest 1 min data of indices over last 5 years??
@Algovibes
@Algovibes 2 жыл бұрын
I have covered that in this video: kzbin.info/www/bejne/fnOUdH-wZb9khLs It is on cryptos but maybe you will find something of value there as well!
@meetshah4800
@meetshah4800 2 жыл бұрын
@@Algovibes What should be changed as per video in code for Banknifty indices??
@meetshah4800
@meetshah4800 2 жыл бұрын
For stock market
@boomerz2478
@boomerz2478 2 жыл бұрын
All of your videos make the (understandable) German mistake that all markets and activity are rational and can be understood with logic and reason. This is true maybe 80-90% of the time but that 10-20% can really fuck you over if you have no way to adjust or control for it which you never seem to do. And that small percent can wipe out all of someone’s gains.
@Algovibes
@Algovibes 2 жыл бұрын
Wait. Wasn't it the Americans who crashed our finance system and not the germans? 😛
@apurvaparekh9364
@apurvaparekh9364 3 жыл бұрын
great video, just came on my time line somehow. thanks for the simple explanation. do you have an email ID where I can reach out to you to get some doubts cleared for a similar strategy am trying to code ? cheers and god bless.
@Algovibes
@Algovibes 3 жыл бұрын
Hey mate, thanks a lot for your kind comment :-) Unfortunately I don't have a KZbin related mail yet but I will provide one in the about me section very soon.
@sofienesdiri8470
@sofienesdiri8470 3 жыл бұрын
Can we apply this strategy on crypto?
@Algovibes
@Algovibes 3 жыл бұрын
Thank you very much for watching and your comment. Yes, this is also applicable to cryptos. There will be some crypto trading coverage as I am doing that myself in the near future. Thanks for your patience :-)
@sofienesdiri8470
@sofienesdiri8470 3 жыл бұрын
@@Algovibes i appreciate your work
@siddharthterse8563
@siddharthterse8563 3 жыл бұрын
Hi Algovibes, Can you please share your email ID please, for enquiry ? if you are interested in project related with your skills ?
@Algovibes
@Algovibes 3 жыл бұрын
Hi and thank you very much for the request. Appreciate it. I will add an email in the upcoming weeks in the about me page.
@tayaamme9954
@tayaamme9954 2 жыл бұрын
Hi Algovibes, Thank you very much for all the helpful videos you make. I am trying to backtest a strategy where the asset is sold when my tp percentage is met or when the chart goes for example 1 bar in the other direction. And then I want to convert the trade to a trade in the other direction. I've tried this code, but it only calculates the first exit. I also tried the code from the video kzbin.info/www/bejne/qJTCimmomaekjq8 but it also doesn't work the way I want. I modified the codes to my liking, but unfortunately it still doesn't work the way I want. I've been searching for the right code or combination of code for several days now. I also watched all your videos in the Python for Finance playlist. What could I change in one of your codes to get this working? I hope you have time to help. Thanks again.
@Algovibes
@Algovibes 2 жыл бұрын
Thanks a lot Taya, well I can't tell. But let me tell you it is nothing unusual to come across things not working. To figure out why it doesn't work can take days or even weeks. Just try to understand why it doesn't work and try to slice the problem in as small chunks as possible.
@tayaamme9954
@tayaamme9954 2 жыл бұрын
@@Algovibes Thanks for the reply. It's so frustrating sometimes when something doesn't work out and when you've been doing it for so long. I solved the problem for now by adding extra columns with new conditions. We are now testing and fine-tuning the strategy. If this is a profitable strategy, we are happy to share it with you. Your videos are really helpful, thanks again for all you do.
He bought this so I can drive too🥹😭 #tiktok #elsarca
00:22
Elsa Arca
Рет қаралды 45 МЛН
Running With Bigger And Bigger Feastables
00:17
MrBeast
Рет қаралды 205 МЛН
Simple Trading Strategy on Bitcoin with Python FULL walkthrough
37:03
Fundamental Analysis of Stocks with Python
19:09
Algovibes
Рет қаралды 28 М.
Automated Price Break Out Detection: Algorithmic Trading In Python
16:34
Backtesting Candlestick Patterns in Python
27:45
Chad Thackray
Рет қаралды 21 М.
He bought this so I can drive too🥹😭 #tiktok #elsarca
00:22
Elsa Arca
Рет қаралды 45 МЛН