Algorithmic Trading Strategy [Mean Reversion] in Python using Bollinger Bands/RSI !BEGINNER FRIENDLY

Поделиться
HTML-код
  • Опубликовано: 7 июн 2024
  • In this video we are building and improving an Algorithmic Trading strategy presented on LinkedIn which I consider is quite beginner friendly. Let me know if you are interested to test that on a larger scale, on cryptocurrencies or whatever you are interested in. Happy to cover!
    Get the Notebook/Source code by becoming a Tier-2 Channel member:
    / @algovibes
    Bryan Chens article:
    / algorithmic-trading-me...
    I am refering to Bryan as "the author" in the course of this video.
    Build the RSI from scratch:
    • How to build a RSI Tra...
    Another RSI/Bollinger Bands Trading strategy implemented in python:
    • Backtesting Rayner Teo...
    How returns are calculated and cumulated:
    • How To Calculate Stock...
    In depth Bollinger Bands:
    • Algorithmic Trading in...
    Be invited to check out more videos in my Python for Finance playlist and the cryptobot playlist and most importantly:
    Please subscribe if you want more of this content! Thx :-)
    Disclaimer: This video is not an investment advice and is for educational and entertainment purposes only!
    00:00 - 01:18 Introduction / Disclaimer
    01:18 - 05:16 Pulling prices / technical indicator calculation
    05:16 - 07:24 Numpy select for multiple conditions (must watch!)
    07:24 - 07:58 Check signal column
    07:58 - 09:52 Shifting signal logic / buyprice
    09:52 - 14:06 Checking signals iteratively using iterrows
    14:06 - 15:34 Vizualisation
    15:34 - 16:24 Comparison with the authors signals (new data)
    16:24 - 18:18 Profit calculation / comparison
    18:18 - 21:55 Improving the strategy: Adding Stop Loss
    21:55 - 23:46 Other stocks / potential upcoming videos!
    #Python #Trading #Strategy #BollingerBands #RSI

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

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

    Very elegant way to create the 'signal' column. 👍

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

      Glad that you think so :) thanks for watching!

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

    As usual... great info and very well explained... I really love your channel, it's extremely helpful

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

      Thanks a lot Marc. Appreciate your kindness!

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

    Awesome analysis and great to see this all done in Python, I've only really done things in Tradingview Pine Script :)

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

      Thanks mate, happy to read :-) Be invited to check out my other stuff!

  • @refaamoe
    @refaamoe Год назад +2

    I swear I love this channel 😍

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

      Thank you so much! Channel loves you too ❤️

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

    Great Video. You The Man!!❤‍🔥

  • @ramshankarmukherjee1364
    @ramshankarmukherjee1364 Год назад +3

    I think if you add sma20 like above in buy and below in sell the result will be better as it will follow trend . Thanks for sharing knowledge 🙏🙏🙏 .

  • @user-pi9po1vi9j
    @user-pi9po1vi9j Год назад +2

    Thanks for sharing! Nice job! I like the way you do experiments. Could you make videos on risk management of assets when, for example, they cointegrate? Or other types when we need to care about risks. Thank you and good luck!

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

      Thanks a lot Mansur! Did some videos on that already (e.g. VaR). Is that what you are looking for?

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

    Very interesting as always :)

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

      Thanks a lot Dennis 🙂

  • @int2str
    @int2str Год назад +8

    When the trading is restricted to one active trade at a time, the algorithm becomes extremely starting point sensitive. Basically you'll select which shares to buy simply based on when you set the starting date for the algorithm. I think that basically makes it random.
    Would be great to see a video where you code up a way to take an algorithm like this and programmatically check starting point sensitivity.

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

      Thanks a lot for sharing your thoughts Andre. I have already covered to tackle that "problem" by e.g. splitting in some previous videos but will also cover that in future videos.

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

    thanks for the video mate, interesting stuff!

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

      Glad you think so Gianluca, thanks a ton!

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

      Seems difficult to test properly and avoid overfitting though given these strategies don't do many trades

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

    great video, thank you very much

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

      Very welcome! Thanks a lot for watching and leaving a comment :-)

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

    Simple and effective as usual. Bravo! A humble proposal : what about to use a correlated couple of futures, such as ES and NQ and to trade their spread ? Instead of a single equity?

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

      Thanks a ton! Also great suggestion, thank you

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

    Great vid thank you...Would be cool to plot the cumulative sum of the returns to see how stable returns are and drawdowns....

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

      Thanks mate. You can just take the cumulative prod (cumprod()) instead of the prod and then plot it.

  • @bryan-9742
    @bryan-9742 Год назад +8

    whats really helpful, and tricky, is taking your videos and turning them into Classes. so tricky sometimes.

    • @aricanto1764
      @aricanto1764 Год назад +2

      Facts. Surely a bunch of commenters start a git if his videos with python classes lol

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

      Will do so in the next video! :-)

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

    Ty good video

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

      Thanks for watching mate

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

    Nice

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

    When using the panda.ta (instead of ta) for the RSI, there are only 4 buy dates instead of 10+ as in the video. I am not sure why there is the discrephencies. Any idea?

  • @TexasTrucker-nx8dd
    @TexasTrucker-nx8dd 5 месяцев назад

    Mean reversion and trend following are two opposing trading methodologies. You need to separate the trending market from the range bound market. Only then will you be able to make this better.

  • @itayhilel2168
    @itayhilel2168 Год назад +4

    nice, lets test it on crypto!!

  • @bryan-9742
    @bryan-9742 Год назад

    Why don't you just make the stop losses part of the selling conditions? I'm having trouble understanding why you would put them in the loop? I could only understand that in my mind if they were trailin stop losses.
    Your thoughts are appreciated.

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

    Thanks for this. I am using finta TA and the RSI differs from yours - which one are you using please ?

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

      Welcome mate! Using the RSI from the library here. Has a default lookback of 14. Cheers

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

    Good vdo.

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

      thanks buddy. appreciate your comment!

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

    Is there a python package which can read the raw data of ninjiatrader?

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

    He might have shifted to the second day close to account for a position draw down. There were buy signal clusters and if you look at the close of first to second you have a large draw down. Look at first to third signal you have an even larger draw down. You would be stopped out with a major loss entering the first two signals

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

    Is there any way to set the symbol with a variable so that i can just change the symbol on the top once and it hut run and runs everything for that new symbol

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

      Hey Arman,
      Yes! Will exactly show how to do that in the next video :-) stay tuned

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

    I couldn't understand the part where the position variable set equal to False and in the loop after that we use "if not position" argument which actually turns the argument to true. So in the beginning of the loop we say "if we are in a position and signal is buy....".

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

      Hey Cem,
      no in the beginning we say "if we are NOT in a position AND we have a buying signal" -> Buy!

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

    Very interesting 😍😍😊😘😘🤩💕💕❤️

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

      thanks buddy

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

      @@Algovibes💕💕❤️❤️❤️❤️🤩

  • @k2icc
    @k2icc Год назад +3

    Maybe an MA or something to filter the larger fall at the end?

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

      Probably not a bad idea! Thx for watching :-)

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

      @@Algovibes Well, I was using the Pinbar rejection indicator from TradingView, which is almost an identical plot as the Bollinger Bands middle line, and it catches that big downside move on the chart. Tanks.

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

    Shared code

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

      Sure! You get access to the Code by becoming a Tier-2 channel member here:
      ruclips.net/channel/UC87aeHqMrlR6ED0w2SVi5nwjoin
      Looking forward to welcome you! :-)

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

    I am surprised to see GME yielding a 126% return if you start the strategy from beginning of this year. I used a 5% stop loss

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

      Yea, that's quite interesting indeed.

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

    please how do you take profit

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

      You mean like instead of the Stop Loss add a Target Profit?

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

    All strategies perform nice to very nice when there's a bull market. Unless you can start accounting for/predicting the market bull-bear-wise, all strategies will always fail.