How to build a RSI Trading Strategy and Backtest over 500 stocks in Python [70% Winning Rate]

Поделиться
HTML-код
  • Опубликовано: 20 дек 2024

Комментарии • 283

  • @Algovibes
    @Algovibes  3 года назад +13

    In case you are interested how to build this strategy WITHOUT overlapping positions watch this:
    ruclips.net/video/rYfe9Bg2GcY/видео.html
    BTW Thanks a lot for all your comments no matter if they were positive or constructive criticism!

  • @gibson7392
    @gibson7392 3 года назад +21

    Thank you for a non-clickbait honest video. Straightforward and well explained.

    • @Algovibes
      @Algovibes  2 года назад +1

      Thanks a lot for watching! :-) Well the thumbnail is catchy tho :D

  • @grizthegriffdog9939
    @grizthegriffdog9939 3 года назад +7

    mostly IM just amazed how you can whip up your own backtest within minutes! What a display of mastery over the language, so much to learn! Thanks

    • @Algovibes
      @Algovibes  3 года назад +11

      I appreciate your kind words but there is nothing to be amazed about. I invested some time building the strategy before recording the video and definitely had some difficulties here and there.
      But nevertheless I appreciate your kind words :-) Just keep on grinding, coding and always be keen to learn new stuff and with a little bit of patience you will outdistance me in no time ;-)

  • @ayush2626
    @ayush2626 2 года назад +2

    Thank you for this turorial! Exactly what I was looking, every other tutorial was focused on just one stock.

    • @Algovibes
      @Algovibes  2 года назад

      Awesome :) Thanks a lot for watching!

  • @josuecc7843
    @josuecc7843 3 года назад +10

    Regarding the df.ewm().mean() function, you can also specify directly the Smoothing factor as an argument :
    def RSI(ticker, period=10):
    df['avg Up1'] = df['Upmove'].ewm(alpha=1/period).mean()
    That way, you don't have to do the conversion each time you want to modify the RSI' time period

    • @Algovibes
      @Algovibes  3 года назад +3

      Very good idea! Thanks for sharing :-)

    • @josuecc7843
      @josuecc7843 3 года назад +2

      @@Algovibes Your welcome, great video as always by the way ! :)

    • @Skandawin78
      @Skandawin78 3 года назад +1

      Exactly what I was looking for. I assume the code in this video is for 19 period RSI right?

    • @goodyonsen77
      @goodyonsen77 2 года назад

      @@Skandawin78 actually period of 10 when the simplification is done, which is what he intended for as WSM isn’t a function in Python. So he used ewm() with span of 19 to make the denominator sums up to 20, to reach 10 when 2/20 takes place.

    • @maxmat_
      @maxmat_ Год назад

      Top Content!

  • @victorbartolo287
    @victorbartolo287 3 года назад +3

    my complements for an excellent presentation. It is useful for both python and finance learners. Well done

    • @Algovibes
      @Algovibes  3 года назад

      Thank you very much for watching and your kind comment. Happy to hear it is useful :-)

  • @davidh4632
    @davidh4632 2 года назад +2

    Love your channel for python coding. Essentially this is just a positive momentum strategy with a take profits built into it. As you show in 3m chart there are no signals when stock trends down in price. Momentum is fine to trade but you need to avoid crashes, the sell signal via short term rsi does this here but also misses out on profits from a buy hold strategy when the stock moves higher over a long period. Unfortunately a pure price based strategy will never work all the time, this is a great start though.

    • @Algovibes
      @Algovibes  2 года назад +1

      Thanks a lot David. Very good point! Be invited to check out my other stuff :-)

  • @dariodegennaro5468
    @dariodegennaro5468 3 года назад +4

    Great work. I would like to point out a couple of things though.
    1) to avoid over-exposing yourself to a security, you should first check if we have already a position open with that security and avoid investing again.
    2) this strategy live may turn out to be a losing one because this doesn't account for brokerage fees (sometimes they may be a percentage of the investment and turning some of the wins in a loss anyways). So maybe the win rate may be definitely lower than that.

    • @Algovibes
      @Algovibes  3 года назад

      Hi buddy, thanks a lot for your comment and sharing your thoughts!
      I addressed the first point in this video only allowing one open position at the time:
      ruclips.net/video/rYfe9Bg2GcY/видео.html
      Regarding the second point: Definitely true!
      Adding brokerage fees to a strategy is technically no big deal.
      Backtrading libraries such as backtrader are just taking a fixed amount and subtracting that from the profit.
      You can extend that when calculating the profits with a simple loop or list comprehension.

  • @hamad.learns
    @hamad.learns 3 года назад +1

    Always happy to like a fellow python algo trader !

    • @Algovibes
      @Algovibes  3 года назад +1

      Thanks for watching. I appreciate your comment :-) Nevertheless I wouldn't consider myself an algo trader. At least as long as my salary is above my (average) trading profits :-D

    • @hamad.learns
      @hamad.learns 3 года назад

      @@Algovibes haha funny way to put it. Actually I use python mostly for research. No automated trading for me, however I aim to be systematic

  • @Skandawin78
    @Skandawin78 3 года назад +1

    Excellent Videos.. I have created my Ichimoku buy/sell program based on your videos. Thank you so much.

    • @Algovibes
      @Algovibes  3 года назад

      Thanks mate. And..? Does it work in your desire? :D

    • @Skandawin78
      @Skandawin78 3 года назад

      @@Algovibes yes , I do less manual scanning of charts .. thanks 🙏

  • @Dwer172
    @Dwer172 3 года назад

    About the alpha of the moving average:
    The number of periods (N) should actually be 4.5. Rounded to 4 or 5, at your preference.
    Rationale: let W(ilders) be the number of periods to calculate.
    2/(N+1) = 1/(W+1)
    2W + 2 = N + 1
    2W = N - 1
    W = (N - 1) / 2
    given N = 10 then W = (10-1)/2
    W = 9/2 = 4.5
    great job 'pythonizing' the rules of the system!
    JB

    • @Dwer172
      @Dwer172 3 года назад

      the rule of thumb for finding the number of periods for an RSI calculated with an exponential MA is dividing the number of periods by 2 and add 1.
      the corresponding RSI of an EMA of 200 periods would be an RSI of 100+1= 101.
      better to round it to 100...
      the corresponding RSI for an EMA of 50 periods would be 25 and so on and so forth ;)
      JB

    • @Algovibes
      @Algovibes  3 года назад

      Hi mate, really appreciate your comment!
      Could you elaborate on 1/(W+1) ? Wanna make sure we are on the same page.
      Thanks in advance!

    • @Dwer172
      @Dwer172 3 года назад

      ​@@Algovibes I'm sorry for the huge amount of time to answer you.
      I didn't notice your reply.
      I went back and check the video.
      The alpha wilder uses is 1/N and not 1/(N+ 1). My bad. :(
      correcting the equation:
      Rationale: let W(ilders) be the number of periods to calculate.
      2/(N+1) = 1/W
      2W = N + 1
      W = (N + 1) / 2
      so the RSI periods corresponding to a 10 periods EMA would need to be
      (10+1)/2 = 5.5 rounded to 5 or 6 at your discretion.
      JB

  • @timmorgan2650
    @timmorgan2650 2 года назад +1

    Really interesting video. Even more refreshing to see a content provider who actually responds to comments and engages with his followers.
    I'm intrigued by this but it also went 95% over my head. For example, what is this editor you're using? It looks like you're just writing this in Safari. Can you please point me to a Python intro video(s) to get me up to speed to better understand what you are doing here?

    • @Algovibes
      @Algovibes  2 года назад +2

      Hi Tim,
      thanks a lot for your comment. Happy to read!
      You are invited to check out my 1 Hour Python Crash course including all tools I am using and the programmatic basics you will need here:
      www.udemy.com/course/python-programming-fundamentals-in-one-hour/learn/quiz/5570936?referralCode=3E7C3A477A10A7933AA6
      For a free option (but less structured probably) you can check out both the Python Introduction playlist and the Python for Finance.
      Cheers!

  • @timmorgan2650
    @timmorgan2650 2 года назад +2

    At 28:00 you calculate the profits on 3M. The array shows a bunch of 0.0xxxx numbers. I don't understand how that correlates with profits. For example, the first item in the array, 0.01841858, is that a percentage profit where you need to move the decimal place (i.e. 1.84% profit)?
    Also, right after that at 29:13, you calculate a winning rate of 0.837837%. That mean 83% of the trades on 3M were profitable, not that you made a 80% return on 3M, right?
    As I understand the strategy, you're opening the trade when RSI hits 30 and closing it at the earlier of when RSI hits 40 or 10 days later, whatever comes first. Unless I missed it, I didn't see anywhere you placed a stop-loss. So I believe there is no limit on the loss on the trades closed 10 days later because they never hit 40 RSI? If so, what kind of actual profit does the strategy generate? Because if I close 8 out of 10 trades profitably at an average profit of $10/trade but close 2 out 10 for a loss of $100/trade, that strategy would still loose money despite winning 80% of its trades.

    • @Algovibes
      @Algovibes  2 года назад

      Hi Tim,
      first question: yes, exactly.
      Second one: Also, exactly!
      Didn't place a stop loss at all here, that's right.
      I am playing a bit around with stop losses e.g. here:
      ruclips.net/video/4MnNft7Squk/видео.html
      or other videos in the Python for finance / cryptobot playlist. Be invited to explore my stuff - I have tons of content!

    • @timmorgan2650
      @timmorgan2650 2 года назад

      ​@@Algovibes I'll definitely check out your other videos. I hope you're making a ton off adverts. You deserve it for putting quality content out there that isn't just click-bate.
      One question about this strategy, do you know it's PROFITABILITY return? Not percentage of winning trades but actual return on investment.
      I'm just curious because it's mathematically possible to win on 83% of trades while still loosing money overall if the size of the losses, on average, is double the size of the wins. Most strategies I've seen try something along the lines of shooting for 2:1 win amount:-to-loss amount. Meaning, they're usually placing a stoploss around 1/2 the amount of their take-profit to only risk half of what they hope to gain. I'm curious what the effect is of having neither a fixed takeprofit or stoploss has on the size of the wins and losses.
      But, hey, impressive winning rate regardless.

  • @RafeedChowdhury
    @RafeedChowdhury 3 года назад +1

    Great video! This one is cleaner and also with more tickers we'll get more signals. I think I have to tweak this code a little bit to get the each ticker names and last date of signal trigger to run it daily for new signals. And also I think we have to have a code which checks every day if the selling condition is fulfilled for the trades we took to make it autonomous. Anyway great video. Looks very promising. Keep up the good works!

    • @Algovibes
      @Algovibes  3 года назад +3

      Thanks for watching! It seems like you can read my mind :-P The next step would be similar to what you have described. A deployment for a notifier or maybe even a (very simplified) API would be very nice or what do you think? I will work on something like that in the near future, but still have some more topics I want to cover before.
      Cheers and thanks for your input. I really appreciate it!

  • @anlamkemalyuksekli2675
    @anlamkemalyuksekli2675 2 года назад +2

    Thanks a lot and i have subscribed. While ı have been coding ı have faced with this error:
    "cannot set a frame with no defined index and a scalar"
    Do you have any suggestions?

    • @Algovibes
      @Algovibes  2 года назад

      Can you provide me a timestamp in the video when you are getting the error? Did you deviate from my code in some way?

    • @Algovibes
      @Algovibes  2 года назад

      BTW thx a lot for subscribing mate :-)

  • @sagarchoudhari9386
    @sagarchoudhari9386 3 года назад +1

    You are doing a very good ! keep making content on Stocks and Crypto

    • @Algovibes
      @Algovibes  3 года назад

      Thank you very much for your feedback. Really appreciate it :-) There will be more on both topics!

  • @sz8558
    @sz8558 3 года назад +2

    The only potential "pitfall" to this strategy, if I can call it that, is that the strategy can become highly levered if multiple BUY entries are entered on consecutive days for a particular stock - potentially increasing levered to 10x if BUY conditions occur day after day...Would be good to see how we can limit it to have only one order open at any time.

    • @Algovibes
      @Algovibes  3 года назад

      Absolutely agreed! I don't check for open positions in this strategy. When going live with it, one definitely should and also apply a risk reducing mechanism.

  • @bivekneupane067
    @bivekneupane067 2 года назад

    Hi, could anyone please explain to me why at 33:00 we do range(len(df)-11) ? The minus 11 part is really confusing. Any help is greatly appreciated. Thanks

  • @kulinshah
    @kulinshah 3 года назад +1

    Continue @ 13:35 bookmark fir for self

    • @kulinshah
      @kulinshah 3 года назад +1

      20:55

    • @Algovibes
      @Algovibes  3 года назад

      Haha, awesome :-D I hope you had a good time watching this video.

  • @edwardburroughs1489
    @edwardburroughs1489 3 года назад +1

    Excellent video. How did you know to look at the 0th index when reading the HTML with pandas? That doesn't seem intuitive?

    • @Algovibes
      @Algovibes  3 года назад

      Thanks mate. Pretty straightforward: I checked the website and was indexing for the relevant table.

    • @edwardburroughs1489
      @edwardburroughs1489 3 года назад

      @@Algovibes I see. I knew pandas could read excel/csv never knew about the read_html function. It seems very useful.

  • @Dulle88
    @Dulle88 3 года назад +3

    Subscribed! Absolutely great video! I love the detailed explanation in every step. That is very helpful for me as Python beginner. It is interesting to see you calculating everything "by hand" but what do you think about using libraries like TA-lib or backtrader which make some parts easier?
    (Actually I came accross your video by looking for backtrader tutorials.)

    • @Algovibes
      @Algovibes  3 года назад +6

      Hey mate, thank you so much for watching, your kind words and subscribing. Appreciate it! My point in calculating it by hand is to teach programming stuff like that. It is the same concept as teaching ML algorithms from scratch even though there are powerful libraries:
      It is nice to know what's going on in the background.
      I have used a library in my stock recommender video in case you are interested: ruclips.net/video/AuZmsv6dQCM/видео.html
      I plan to make a backtrader tutorial. Can't promise anything but at least it is on my list!

  • @knarim1
    @knarim1 Год назад +1

    Hello. But how do we get data for real-time RSI calculation? Thanks for the reply. 👍

    • @Algovibes
      @Algovibes  Год назад +1

      Hi mate, got a ton of content which is addressing exactly that in the cryptobot playlist. Cheers!

  • @thinketh2408
    @thinketh2408 2 года назад +1

    Just found your amazing channel...
    I was wondering what is your favorite strategy for alog trading....

    • @thinketh2408
      @thinketh2408 2 года назад +1

      And which algorithm do you use your self for making trades?

    • @Algovibes
      @Algovibes  2 года назад +1

      Thank you! :-)
      There is no "THIS algorithm" (would be awesome if there would be, right? 😁)
      Be invited to check out the cryptobot playlist. I am playing around with a lot of strategies ranging from momentum, reversal to technical indicators.

  • @amirmoezi8316
    @amirmoezi8316 3 года назад +1

    Thanks a million for your invaluable content... it's just wonderful

    • @Algovibes
      @Algovibes  3 года назад

      Thank you ☺️
      You may want to check out this one as well. I fixed the code for only one open position at once:
      ruclips.net/video/rYfe9Bg2GcY/видео.html

  • @LittleSheep
    @LittleSheep 3 месяца назад +1

    Hello sir,I'm new about Algo. Please teach me step-by-step how to put in at live trading and trade by bots. Using this strategy. Can test this by demo account ?

    • @Algovibes
      @Algovibes  3 месяца назад

      Hi mate,
      I have a ton of resources both free and also more deep diving paid resources. Check out the Info page here where you will find all necessary links. Let me know if you don't find something you are looking for!

  • @over6128
    @over6128 3 года назад +1

    Very cool video, thanks for sharing - quick question: How would you edit this into a buy only strategy without any automatic selling & view the cumulative return up until the last datapoint?

    • @Algovibes
      @Algovibes  3 года назад +1

      Thanks for watching buddy :-)
      You could apply a similar logic as the one in my most recent video. But you somehow need an exit in my opinion.
      Video:
      ruclips.net/video/vWVZxiaaTCs/видео.html

    • @over6128
      @over6128 3 года назад +1

      @@Algovibes Thanks!!

  • @mm9128
    @mm9128 2 года назад +1

    Thank you for your knowledgeable video. I want to know, which python compiler software you are using for coding in this video.

    • @Algovibes
      @Algovibes  2 года назад

      Hi man, thanks a lot for your comment. I am using Jupyter Notebook here.

  • @yisiangong4842
    @yisiangong4842 3 года назад +1

    Great Tutorial.
    May i know how do you know which data to pop when you run the final backtesting?
    Thank you

    • @Algovibes
      @Algovibes  3 года назад

      Thank you my friend! Can you give me the timestamp?

  • @bala8959
    @bala8959 3 года назад +1

    I don't see any buy signals for month of December 2021, will it not generate daily signals?

    • @Algovibes
      @Algovibes  3 года назад

      Depends if the conditions are fulfilled.

  • @TheWorldGameGeneral
    @TheWorldGameGeneral 2 года назад +1

    but all these trades do not calculate comissions right?
    How do we trade with a bot without paying the comissions ar atleast account for them?

    • @Algovibes
      @Algovibes  2 года назад

      Right!
      Covered topics like that in my cyptobot playlist. Be kindly invited to check that out!

  • @javierblas6956
    @javierblas6956 2 года назад +1

    is there a code I could use to link the all profits to their respective tickers?

    • @Algovibes
      @Algovibes  2 года назад +1

      You could just map the symbols to the returns. I have shown how you can do that with e.g. a DataFrame and a zip function here:
      ruclips.net/video/YFRJ_9RVrz4/видео.html

  • @vladvol855
    @vladvol855 3 года назад +1

    Pretty interesting to see implamantation od such stategy in real trading, for example, using IB TWS

    • @Algovibes
      @Algovibes  3 года назад

      Thanks a lot for watching and your comment. I will cover live trading in the near future (somewhen between May and July). Anyhow there are some adjustments to be made before that to this specific strategy.
      This video is just a technical implementation of backtesting the strategy presented by Rayner Teo (or Larry Connors) on a single stock base.

    • @thimojansen5136
      @thimojansen5136 3 года назад +1

      @@Algovibes Cool programming but actually why not give us average profit? Cuz looking at the histogram with 3000+ hits at 0.0001 or some bullshit it looks like we just playing even based on the histogram lol. Win rate doesnt mean shit if our avg +win is way lower then avg -lose.

  • @michaeltolin9795
    @michaeltolin9795 3 года назад +1

    Do you know the best way to understand the revenue from this strategy?

    • @Algovibes
      @Algovibes  3 года назад

      Could you elaborate on "revenue"?

    • @michaeltolin9795
      @michaeltolin9795 3 года назад

      @@Algovibes How much profit from this strategy. Is there a way in Python to calculate how much money would have been made from this strategy?

    • @Algovibes
      @Algovibes  3 года назад +1

      @@michaeltolin9795 Yes sure! I am getting a little more into details on how to do that here:
      ruclips.net/video/rYfe9Bg2GcY/видео.html

  • @arbysfan732
    @arbysfan732 2 года назад +1

    Curious what the magnitude of losses are? For example if you looped through all your wins/losses and did profit = 1; profit*=current_profit, do you still end up losing despite 70%+ win rate?

    • @Algovibes
      @Algovibes  2 года назад

      Good question. The notebook is somewhere on my other laptop. I covered cumulative profits in other vids.
      BTW this might also be interesting for you covering some more measurements:
      ruclips.net/video/rYfe9Bg2GcY/видео.html
      Let me know what you think below that!

  • @ModernEducation7144
    @ModernEducation7144 2 года назад +1

    when I looped through S&P500 stocks it throws an error ValueError: cannot set a frame with no defined index and a scalar ....

    • @Algovibes
      @Algovibes  2 года назад

      did you somewhere deviating from my approach? If not can you pass me a timestamp when this error is occurring?

    • @teprox7690
      @teprox7690 2 года назад

      You could also use try: / except: to exclude stocks with data error. Than you have not to use .pop for every invalid tickers in the top.

    • @Logic_Lab_Robotics
      @Logic_Lab_Robotics 2 года назад

      tickers.remove('CEG') because there is no data on it

  • @tiandeqiang
    @tiandeqiang 2 года назад +1

    Great vedio, but you need calculate transaction fee and slipage,also calculate annual profit,maximum drop down

    • @Algovibes
      @Algovibes  2 года назад

      Thanks mate. Yep, good points. Doing that in follow up videos. Be invited to check out the Python for Finance playlist.

  • @jahirraihanjoy3466
    @jahirraihanjoy3466 2 года назад +1

    what if the datasets are in local storage???

    • @Algovibes
      @Algovibes  2 года назад

      You mean like in csvs or similar?

  • @iamprashantjain
    @iamprashantjain 2 года назад +1

    I like all your videos.. very nice content.. can also make a vide on back testing intraday breakout strategy where we have to do the calculation day wise since it changes everyday in the dataframe

    • @Algovibes
      @Algovibes  2 года назад +1

      Thank you man :-)
      Regarding intraday trading, you could check out my cryptobot videos - maybe you will find something useful there.

    • @iamprashantjain
      @iamprashantjain 2 года назад

      @@Algovibes I need it for backtesting.
      could you please share the link if possible

  • @y.c.breddy3153
    @y.c.breddy3153 3 года назад +1

    Is it possible to add stop loss condition to .ex4 file

    • @Algovibes
      @Algovibes  3 года назад

      I have no experience with .ex4 files.

  • @Magmatic91
    @Magmatic91 3 года назад +1

    Great stuff. Can I do the same thing with Backtrader framework?

    • @Algovibes
      @Algovibes  3 года назад +1

      Thank you mate! :-)
      I didn't test that with BT yet but you probably can.

  • @haovan1674
    @haovan1674 3 года назад +1

    Would love to have a built-in sensitivity analysis for RSI pairs. Like in this case you use 40 as entry/exit pairs and it spits out 70% winning rates. But I'm interested in other pairs - says

    • @Algovibes
      @Algovibes  3 года назад

      Awesome suggestion! I actually did this on SMA pairs already. Maybe you can extract value out of that:
      ruclips.net/video/vWVZxiaaTCs/видео.html

    • @haovan1674
      @haovan1674 3 года назад +1

      @@Algovibes Thanks. Your instructions on the video are very clear. I used to backtest all of this with Excel and just moved to Python recently so I understand the concept but not the code until I saw your video so thank a lot.

    • @Algovibes
      @Algovibes  3 года назад

      @@haovan1674 Awesome. I have a lot of other stuff on that topic. Be kindly invited to check that out and let me know what you think :-)

  • @mindhive-musicmeditationlu8270
    @mindhive-musicmeditationlu8270 3 года назад +1

    Thanks buddy for sharing this
    Hope you do lore like these

    • @Algovibes
      @Algovibes  3 года назад

      Thank you mate :-) Yes there will be more trading strategies!
      Until then be kindly invited to check out the other ones on this channel.
      Best regards and I am happy to have you on board.

  • @marcinziom7013
    @marcinziom7013 2 года назад +1

    Hi i had also problem with 'OGN' placed at index 357, after first two pop's (474, 489). So i think at start it had an 359 index.

    • @Algovibes
      @Algovibes  2 года назад

      Hi man, thx for sharing that!

  • @Skandawin78
    @Skandawin78 3 года назад +1

    You must be a millionaire implementing these programs 🤑

  • @8ksmiff502
    @8ksmiff502 3 года назад +1

    Hello ! I have parse data with my python file and getting the result in python console, now I want to export this data to google sheet. Can you help me to do that ?

    • @Algovibes
      @Algovibes  3 года назад +1

      Hi,
      sure! What exactly are you struggling with?

    • @8ksmiff502
      @8ksmiff502 3 года назад

      @@Algovibes Thanks for the response! I found the solution by just copying it and pasting into excel by applying "data to table formula". However, I would be thankful to you, if you guide me with the code for exporting the data directly into excel. Pls give me your Discord ID if possible.

  • @pucek365
    @pucek365 3 года назад +1

    It would've been nice idea for the future to take an integral of this last graph to see if it really is profitable, because right now you cannot see if it is profitable or not. What i mean is maybe the graph on the left side of 0 has higher total area than the one one the right of 0, and then the strategy would perform quite badly.

    • @Algovibes
      @Algovibes  3 года назад

      Hi mate, thanks a lot for your comment and your suggestion! I am getting more into details about metrics in this video:
      ruclips.net/video/rYfe9Bg2GcY/видео.html

  • @sherlock27
    @sherlock27 3 года назад +1

    Thanks. So the next thing is how to create telegram bot / signal from this strategy?

    • @Algovibes
      @Algovibes  3 года назад +1

      Not using both of them but the suggestion to connect a trading signal to another application if that's an app or a mail or whatsoever is actually quite nice. Thank you very much for sharing your idea :-)

  • @az-ed4gp
    @az-ed4gp 2 года назад +1

    great video! thanks so much!

    • @Algovibes
      @Algovibes  Год назад

      Welcome buddy. Thanks for watching :-)

  • @minhducbui9660
    @minhducbui9660 Год назад

    Thanks you for your work . I have a question, if close price > ma200 and rsi < 3 for 3 consecutive days then there will be 3 consecutive buy signals right?

  • @cudanakiju0
    @cudanakiju0 3 года назад +2

    thats an amazing job! could you please provide a 'real life' example of backtesting, for example how much profit would this strategy provide out of 100$? I'd like to see if my calculations are fine ;)

    • @Algovibes
      @Algovibes  3 года назад +1

      Thank you very much for watching and your comment. I will see what I can do :-)

    • @TheChievovr
      @TheChievovr 3 года назад

      Are you sure you want to see? Because if you see it, the illusion finishes

  • @pietraderdetective8953
    @pietraderdetective8953 2 года назад +1

    Awesome video!
    Would be even better if you put the accumulation of equity value to see how's the investment growing over time.

  • @its_sharan54
    @its_sharan54 3 года назад +1

    You are really amazing brother i also used to do all this with python too but i always did it with long method,you actually taught how to convert your strategy to code, hats off to u, liked and subscribed ,keep up the good work

    • @Algovibes
      @Algovibes  3 года назад +1

      Thank you so much! :-) Really appreciate your comment.

  • @quansun7633
    @quansun7633 3 года назад +1

    Hi algovibe. Thanks a lot for the video. The histogram shows a slightly positive mode, so the higher probability of winning; However, the total areas above and below zero are about the same. Does that mean the total wining and losing in terms of dollar amount is about the same?

    • @Algovibes
      @Algovibes  3 года назад

      Hi buddy, thanks for watching. Can you please give me a timestamp?
      In general see the analysis with caution as I don't exclude overlaying trades here. I made the necessary amendments in this video here:
      ruclips.net/video/rYfe9Bg2GcY/видео.html
      Be kindly invited to check that out.

  • @sz8558
    @sz8558 3 года назад +1

    Do you offer python consulting at all?

    • @Algovibes
      @Algovibes  3 года назад

      Currently not, but probably in the future. I am currently spending my spare time to produce content and want to focus on that at least within this year.

  • @kaineis
    @kaineis 2 года назад +1

    Hi Algovibes, first I love your videos and I am kind of watching them non-stop as I also currently build an trading bot for fun.
    Second: What are your thoughts on the python TA library and their calculation on the RSI (they have actually two and am currently try to figure out the difference)?
    Third: How comes that you normally do not use Decimals in your videos? Again I am kind of a beginner in python and I just learned if I have to deal with prices (which are decimal values) I should also make my calculations in decimal instead of float. But maybe I misunderstood the whole topic. So if you have some comment on it let me know.
    Ansonsten, mach einfach weiter diese Videos. Die einfach nur super :).

    • @Algovibes
      @Algovibes  2 года назад

      Thanks a lot man :-) / Danke dir!
      Second question: You mean stoch RSI and RSI?
      Third: Would need some elaboration on that. Until now I didn't run into a problem with float values. I know there are cases which are problematic but I can't imagine a scenario where a float value would crush any trading strategy / risk measurement / ....

  • @Harshavardhan-zl7kf
    @Harshavardhan-zl7kf 3 года назад +1

    can i use rsi for crypto trading??

    • @Algovibes
      @Algovibes  3 года назад

      Well that is a at least in my perception a very general question.
      In general you should see technical indicators not as a reliable thing to predict next moves but rather see them as an orientation and combine them with other indicators.
      I tested a set of technicals in this video and considered cryptos in the very end:
      ruclips.net/video/r8pU-8l1KPU/видео.html

  • @luissar32
    @luissar32 2 года назад +1

    hi, this line profits= (frame.loc[sell].Open.values - frame.loc[buy].Open.values)/frame.loc[buy].Open.values eventually maybe after 50 or 60 successfull data download throws raise KeyError(f"{not_found} not in index"), i have tried with iloc but i cannot make it work, also with frame.reset_index and reindex, nothing works.
    KeyError: "[Timestamp('2020-10-27 00:00:00'), ... , Timestamp('2020-12-30 00:00:00')] not in index"

    • @Algovibes
      @Algovibes  2 года назад +1

      Hi Luis,
      you can work with a try / except logic or simple if logic to drop empty tables. Should solve the problem. Cheers!

  • @trstscl
    @trstscl Год назад +1

    Sehr interessant ! Cooles video

  • @marfav123
    @marfav123 2 года назад +1

    In the future, can you show us how to see the performance of any given amount of money put into any of these stocks? That way we can see how much money you could theoretically have made if invested in a certain stock with a certain amount of money. Thank you

    • @Algovibes
      @Algovibes  2 года назад +1

      Hey Marco, be invited to explore the videos on my channel - in specific the Python for Finance and cryptobot playlist.
      I have covered that in many of my videos. Let me know if you don't find anything!

    • @marfav123
      @marfav123 2 года назад

      @@Algovibes thank you so much. I really appreciate. I will definitely check them out. I know that I along with many others appreciate the knowledge and time u share with us. Keep doing what you are doing.

  • @forisraelforever
    @forisraelforever 3 года назад +2

    Thank you very much for this video. Can you please share the code in your videos?
    And can you write a trading bot for this strategy? I just wanted to see how you build the bot if you check for over 500 assets.

    • @Algovibes
      @Algovibes  3 года назад

      Welcome man! Trading bot is actually a quite nice idea. Thanks for the suggestion!

  • @photosotos8728
    @photosotos8728 2 года назад +1

    How to integrate it with real time broker api

    • @Algovibes
      @Algovibes  2 года назад

      Check out my cryptobot playlist pls. I am applying some strategies on live data there using APIs.

    • @photosotos8728
      @photosotos8728 2 года назад +1

      Ok

  • @Johnsormani
    @Johnsormani 4 дня назад +1

    Slippage, spread, delays etc will make a big difference in the real world

  • @n0n084
    @n0n084 2 года назад +1

    Thank you for this interesting introduction. Trying to reproduce it I'm surprised to have different values in Adj Close column, and this leads to really a lot of trades for those 503 assets (800k since 2011) and a winning rate of 56%.
    Any idea why Adj Close column has been adjusted several years after quotations?

    • @Algovibes
      @Algovibes  2 года назад

      Welcome mate. depends on whether there were dividend actions, stock splits or other capital actions. BTW please check out this video here: I was getting rid of overlapping trades etc.:
      ruclips.net/video/rYfe9Bg2GcY/видео.html

  • @wSevenDays
    @wSevenDays 3 года назад +1

    Do you plan on using Backtrader? Using `imaginary` trades and real trade simulation with a backtrader can differ by a considerable margin.

    • @Algovibes
      @Algovibes  3 года назад

      Thanks for watching mate. Are you referring to the Backtrader python library? If yes, I already took a look at that and will release some stuff on it in probably the near future.

    • @wSevenDays
      @wSevenDays 3 года назад +1

      @@Algovibes yes, also you can see my other comment, I reproduced the algorithm on TradingView. Both platforms are great for backtesting, thanks

    • @Algovibes
      @Algovibes  3 года назад

      Funnily I see that comment in my notifications but not in the comment section... Thanks a lot for your input, will have a look at that in the course of the weekend.

    • @tlghnkck
      @tlghnkck 3 года назад

      @@wSevenDays Hi, how did you transfer it to Tradingview?

    • @wSevenDays
      @wSevenDays 3 года назад

      @@tlghnkck I wrote that by myself given the rules from the video

  • @bigden288
    @bigden288 3 года назад +1

    Can you please tell how to run this bot on cloud

    • @Algovibes
      @Algovibes  3 года назад

      I released 2 videos on GCP how to run Python scripts in the cloud. You might find something useful there!

  • @YourNoise
    @YourNoise 5 месяцев назад +1

    how do i get it and how do i deploy it?

    • @Algovibes
      @Algovibes  5 месяцев назад

      what do you mean?

    • @YourNoise
      @YourNoise 5 месяцев назад

      How do I use this?

  • @sz8558
    @sz8558 3 года назад +14

    Perfect example of someone that "really" knows Python.

    • @Algovibes
      @Algovibes  3 года назад +2

      Appreciate your kind words but there is still a lot to learn for me as well :-)

    • @Skandawin78
      @Skandawin78 3 года назад +2

      Yes, for him python is like English/French. He is so fluent and is able to implement seamlessly what he thinks

    • @thinketh2408
      @thinketh2408 2 года назад +2

      Indeed his python skills are amazing...
      However he has way of complicating the simple thing..

    • @ghazalfaris8796
      @ghazalfaris8796 2 года назад +1

      No body can know python lol

    • @Gregorysharkov
      @Gregorysharkov 6 месяцев назад

      Honestly the python code is pretty bad. Sorry to say that to the author. I do not mean to insult him, but rather I encourage to discover about code smells in python. There are hadfull of those.
      In reality, had this code been structured properly, it would have been much easier to explain to the audience.

  • @gittermnd8998
    @gittermnd8998 3 года назад +1

    Can u make a rsi strategy bot for crypto, were it buys at 40 sell at 70 atomatic??, or is there one you already made but i am to new to this channel so thats why i am asking??

    • @Algovibes
      @Algovibes  3 года назад

      I will see that I cover something like that but in my experience this strategy isn't working out. You will need to combine RSI with other indicators for better trading decisions. Anyhow thank you very much for your suggestion :-)

  • @BICARAKRYPTO
    @BICARAKRYPTO 3 года назад

    Can this method be applied for Cryptocurrency?

    • @Algovibes
      @Algovibes  3 года назад

      Hi and thanks a lot for watching. Interesting question mate. Give it a shot and test it. Cryptotickers are e.g. 'BTC-USD', 'ETH-USD'.
      Let me know your results!If you need any support just let me know. I will run the machine again then :-P
      BTW I have some content on cryptocurrency analysis with Python on my channel. Be kindly invited to check that out.

    • @BICARAKRYPTO
      @BICARAKRYPTO 3 года назад

      Thanks mate. I will try it out and share the results with you. I have zero coding knowledge but watching your video is making it seems easier.
      Thanks for the knowledge.

    • @hermannandarusdy9277
      @hermannandarusdy9277 3 года назад

      @@BICARAKRYPTO go search part time larry. He built one and he admitted that it is not profitable based on RSI only. Although, the strategy is a bit different from what it describes above.

  • @koz.b1741
    @koz.b1741 3 года назад

    great stuff, how can we print daily signals out of this?
    thanks in advance

    • @Algovibes
      @Algovibes  3 года назад +4

      Thanks for your comment mate,
      well ad hoc you could check if there is a signal in any of the last rows by just checking if you are getting a 'Yes' value for any of those assets.
      The interesting thing would be getting notified once you are getting a signal. I will release a video on that in the upcoming months. I think that could be pretty interesting.

  • @yudaluz6443
    @yudaluz6443 3 года назад

    The issue with this method is that buy signals appear in pairs (day after day), and in reality if you buy a ticker, you cannot buy it again the next day, before you sell the older lot. Some buy signals appear as 5 in a row for the same ticker. You would run out of cash if you buy and buy and buy without selling first

    • @Algovibes
      @Algovibes  3 года назад

      Good point! Anyhow I am addressing this in the pinned comment 😛
      Be invited to check out the linked video. Would be curious about your feedback!

  • @DiegoSanchez-oy8qz
    @DiegoSanchez-oy8qz 3 года назад

    when i try to get the buying signals the list is empty, could you guys tell me how to fix it thanks !!!

    • @Algovibes
      @Algovibes  3 года назад

      Sure I am very happy to help. Where exactly do you get an empty list? Can you give me a time stamp? Did you follow the steps or did you deviate somewhere?

    • @DiegoSanchez-oy8qz
      @DiegoSanchez-oy8qz 3 года назад

      @@Algovibes min 24:49, i think i did follow the steps, writing the code in the same way

    • @DiegoSanchez-oy8qz
      @DiegoSanchez-oy8qz 3 года назад +1

      now the code is running perfectly !!! i do not know what did happen, but thanks again for your knowledge

    • @Algovibes
      @Algovibes  3 года назад

      @@DiegoSanchez-oy8qz Thank YOU for watching and your kind words :)

  • @oscarriddleus
    @oscarriddleus 2 года назад +1

    after a few backtesting, this methods indeed pulled up the win rate to about 65%~70%, but its benefit diluted either

    • @Algovibes
      @Algovibes  2 года назад

      Thanks a lot for your comment. In this one I didn't cancel out overlaying positions. I actually covered taking only one position at a time here:
      ruclips.net/video/rYfe9Bg2GcY/видео.html
      Let me know what you think!

  • @Emotekofficial
    @Emotekofficial 2 года назад +1

    I am just concerned about the fact that 10 Period RSI is always different than 10 days Candle RSI! I feel there is no correlation between Periods of RSI and Days. Periods just stretches the Threshold and smoothens or Inflate the trend. However a Timeframe of 10 days is the movement with the periods separated by 10 days.

  • @gmmg3220
    @gmmg3220 2 года назад +1

    again perfect

  • @michaelc730
    @michaelc730 3 года назад +2

    great video, but the excellent back-test results are partly due to survivorship bias.

    • @Algovibes
      @Algovibes  3 года назад

      Thanks mate. Yes! You are right. Good point.

  • @scottkelemen
    @scottkelemen 2 года назад +1

    The only problem with this is that the s&p index is not fixed, companies can become listed or delisted. This strategy only tests on those companies that succeeded. Think back to Enron. You would need a s&p list with historical constituents and their delist dates to have a more accurate back test. Just my 2 cents. Great video though.

    • @Algovibes
      @Algovibes  2 года назад

      Hey Scott,
      thanks a lot for your comment. Yes, that's called a survivorship bias. That's definitely a disadvantage of picking index components like I did but the only free way to get a stock universe.

  • @dimachernovolov9821
    @dimachernovolov9821 3 года назад

    Link to Jupiter workbook?

    • @Algovibes
      @Algovibes  3 года назад

      Somewhere on my old MacBook :D Sorry to disappoint you but I didn't share it somewhere yet.

  • @SP-db6sh
    @SP-db6sh 3 года назад +1

    Please make a video on python customizable Dash board for FNO traders with price alert trigger & scanner.
    How to build trading app using a data feed API.

    • @Algovibes
      @Algovibes  3 года назад +1

      Hi mate, thanks for watching and thanks a lot for your suggestion!
      I am planning on something similar in the upcoming months. Hope I can meet your expectation with that.

  • @theaftermath98
    @theaftermath98 2 года назад +1

    bro please can you show us how to pick real-time RSI Values with time frame 2

    • @Algovibes
      @Algovibes  2 года назад

      Covered realtime trading in the Cryptobot playlist. Be invited to check that out!

  • @chapmansbg
    @chapmansbg 3 года назад +1

    Bruder, is it possible to contact you directly?

    • @Algovibes
      @Algovibes  3 года назад

      Not yet. Probably within the next months when I am setting up a mail. Thanks for your patience!

  • @raghuswill
    @raghuswill 3 года назад +1

    Hi Nice tutorial, Thank you for showing us how to do it, I am new to python and pandas, I am getting the below error and i know the stock is not listed more than a year ago so the data is not full for that. how to avoid it
    ValueError Traceback (most recent call last)
    in ()
    3
    4 for i in range(len(tickers)):
    ----> 5 frame = RSIcalc(tickers[i])
    6 buy,sell = getSignals(frame)
    7 matrixsignals.append(buy)
    2 frames
    /usr/local/lib/python3.7/dist-packages/pandas/core/indexing.py in _setitem_with_indexer(self, indexer, value)
    1587 if not is_list_like_indexer(value):
    1588 raise ValueError(
    -> 1589 "cannot set a frame with no "
    1590 "defined index and a scalar"
    1591 )
    ValueError: cannot set a frame with no defined index and a scalar

    • @Algovibes
      @Algovibes  3 года назад

      Sorry for my late reply mate. This comment just popped up...lol.
      You need to exclude the empty ones. I have done that in my newer version here:
      ruclips.net/video/eEqp-iu8eI8/видео.html

  • @goodyonsen77
    @goodyonsen77 2 года назад

    Bro, you’re always on the awesome side of the fence :) But let me complain about few things :) the loop threw errors for BK_B and BKR_B as “no data”. Since in the year of 2022 the other stock (VICI? idk) isn’t listed no longer as SP500 firm, I didn’t bother that. But, along with the WRK, I also excluded those 2 “BK"s. But this time the empty lists of matrixsignals and matrixprofits appended only 125 of the calculated buys and profits.
    I receive a value error “ValueError: cannot set a frame with no defined index and a scalar” for the rest of the data. Please advice how to fix that list error. Thanks my friend.
    ps: I’d say god bless, but I know you’re an atheist, so I say may the cosmos be with you :))

    • @Logic_Lab_Robotics
      @Logic_Lab_Robotics 2 года назад

      tickers.remove('CEG') because there is no data on it

  • @sajjadtabatabaei2625
    @sajjadtabatabaei2625 3 года назад +1

    Thanks for the great tutorial!
    I have a question: There are many different methods to set buy or selling points. But how would you use your budget? Would you spend it all directly on the first signal or split it? for example, you have a buy signal every week, but you have no money because your money is still in circulation. Is there any strategy how to use the budget to generate the biggest profit? I am in the process of testing a few strategies that I have put together myself, but I do not have a clear result yet.

    • @Algovibes
      @Algovibes  3 года назад +3

      Thanks for watching and your comment! This is a great and very interesting question indeed :-)
      Budgeting would be an additional constraint, that's totally right! But I would need to have to dive deeper to give you a reliable answer to that.
      Without quantitative justification ad hoc I would say you need a budget over a certain time. This budget should be flexible meaning we have a part invested and a cash pool (which could be directly connected with capital gains/losses OR a fixed untouchable budget). Designing this strategy would be an awesome project! Also it would be interesting to see if a fixed or flexible cash pool would be more efficient. Never thought about that, thanks a lot for your input.

    • @sajjadtabatabaei2625
      @sajjadtabatabaei2625 3 года назад +3

      @@Algovibes Thanks for your answer! :) I have found very little useful literature on this topic and I am trying a few ideas myself. If something useful comes out, I will inform you ;)

  • @fsvooo
    @fsvooo 6 месяцев назад

    What’s the point of these backtests if they don’t show returns and compare to buy and hold? Winrate is a useless metric alone

    • @Algovibes
      @Algovibes  6 месяцев назад

      check out my other videos - answers your question.

  • @immortalsofar7977
    @immortalsofar7977 3 года назад +1

    Great videos! But I suspect these signals will fade in the coming months as more people watch your videos. LOL

    • @Algovibes
      @Algovibes  3 года назад

      Well, I hope you are right :-D Thanks for watching mate.

  • @nikosje
    @nikosje 3 года назад +1

    Excellent

  • @ngonluatichcuc-placefire6857
    @ngonluatichcuc-placefire6857 2 года назад +1

    Thanks!

    • @Algovibes
      @Algovibes  2 года назад

      Welcome man! Thanks for watching.

  • @User66866
    @User66866 3 года назад +1

    Great video, excellent programming skills! So, in this strategy there is no stop loss, always wait for when it is above of RSI 40? Anyways, thanks for the effort and sharing!

    • @Algovibes
      @Algovibes  3 года назад

      Thank you very much for your comment! Really appreciate it :-)
      There is indeed no Stop Loss. It could and should be considered when implementing it with real money.
      Just to add: The alternative exit (if RSI condition is not happening) is after 10 trading days.

  • @christophkral191
    @christophkral191 3 года назад +1

    You are also a German. Your English accent is my hint^^

  • @batuhanbayraktar337
    @batuhanbayraktar337 2 года назад +1

    thats exactly what ı am lookıng for... Can u share code or gıthub lınk?

    • @Algovibes
      @Algovibes  2 года назад +1

      Awesome :-) Be invited to check out my other stuff. I am publishing the code for channel members. Be invited to become a channel member!

    • @batuhanbayraktar337
      @batuhanbayraktar337 2 года назад

      @@Algovibes
      I don't know if I should get "supporter" or "discord server access". I'll be a supporter if it doesn't matter. If other codes are shared on your Discord server, I can choose it. I'm also building my own bot. Maybe you would like to join. Or you can teach us how to build bots.

  • @SarthakGarg
    @SarthakGarg 3 года назад

    What is the avg of all returns made? Please share this info since it is I guess make information than the winning rate.

    • @Algovibes
      @Algovibes  3 года назад

      As the basic video is about the winning rate I kept that as the reference.

  • @hackedbyai
    @hackedbyai 2 года назад +1

    Hab an deinem Akzent erkannt, dass du Deutsch bist :D

    • @Algovibes
      @Algovibes  2 года назад

      Das ist ab jetzt unser kleines Geheimnis 🤫 Versprochen, dass du es nicht weitererzählst?

    • @hackedbyai
      @hackedbyai 2 года назад +1

      @@Algovibes Versprochen 😎👍🏼

  • @yute-hube779
    @yute-hube779 2 года назад +1

    You could be waiting a year for stock to rise back above its 200 day MA.

    • @Algovibes
      @Algovibes  2 года назад

      yea that could happen indeed.

  • @viveknarkhede9717
    @viveknarkhede9717 2 года назад +1

    Get the code for this stratagy

  • @vsalvato53
    @vsalvato53 2 года назад

    Hi, as a true beginner with Python programming I found your video very interesting; through this script mod could you analize and screen say 10-20 assets which returned the best profit with the lowest number of trades in a give timeframe *say 12 months? Where could I get this script to c&p in Python3? Is there a repository of your scripts?

  • @lucksimi3320
    @lucksimi3320 3 года назад +1

    hI
    Can we get the python code ?

    • @akshatpatel6258
      @akshatpatel6258 3 года назад

      Have you got???

    • @Algovibes
      @Algovibes  3 года назад

      Sorry for my late reply. I didn't get a notification. I didn't publish the code yet.

  • @dhruvgarg4
    @dhruvgarg4 3 года назад +1

    as india nifty50 stocks, it coming out to be 60 %

    • @Algovibes
      @Algovibes  3 года назад

      Thanks for sharing buddy.
      Please check out the updated version avoiding multiple positions and be invited to test it again on nifty:
      ruclips.net/video/rYfe9Bg2GcY/видео.html

  • @ggz3091
    @ggz3091 Год назад +1

    you're eating?

    • @Algovibes
      @Algovibes  Год назад

      😁 Yes, I couldn't resist the 🍪

  • @learnapplybuild
    @learnapplybuild 3 года назад +1

    A Bollinger Band Strategy please

    • @Algovibes
      @Algovibes  3 года назад

      Hi mate, thanks for your suggestion. Anyhow I already covered BBs here:
      ruclips.net/video/8PzQSgw0SpM/видео.html