How to OPTIMIZE Technical Indicators in a Trading Strategy with Python?

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

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

  • @Estrav.Krastvich
    @Estrav.Krastvich Год назад +4

    Probably one of the most practical algotrading/backtesting content on the Web. Most of which is just pure water.

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

      Thanks a lot mate! Be kindly invited to check out my other stuff.

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

    Excellent information and this is the only video on YT with clear method on how to optimize and validate our strategy. Thanks for taking time and sharing your knowledge. Greatly Appreciated and it benefited a lot! Thanks!

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

    This is top notch stuff. Although the total profit of the strategy may not beat buy and hold, the advantage is you are not in the position full time. When you are out of the position, your capital could be invested in another asset if it is in a state that expects to outperform AAPL at that particular time... or you could stay in cash and sleep easier at night.

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

      Agreed! Be invited to check out my newest series. I am going more into details there.

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

    Incredible Algovibes! Never met so clear explantions and so concise code in the same tutorial!!

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

      Very happy to read! Thanks a lot for watching and leaving a comment :-)

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

    this is so much fun to find combinations of SMAs which doe not make much sense but works very well.

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

    This is really great. Very clean and concise code. Well done.

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

      Thanks buddy! Be invited to check out my other stuff :-)

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

    I'd love to see more of these.

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

      Thx for your feedback Dennis! Appreciate it.

    • @JenniferGan-q3k
      @JenniferGan-q3k Год назад

      Hi Dennis Carver, I can guide you how to invest in cryptocurrency. So you can leave me your contact. Regards

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

    Great. It will be nice to expand as stated. Thanks.

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

      Thanks for your feedback, highly appreciated!

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

    you can optimise if you filter where SMA_1 and SMA_2 have inverted values.
    ex. SMA_1=10 and SMA_2=15 vs SMA_1=15 and SMA_2=10

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

      ahh, I just threw away all values where sma_1 > sma_2

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

    very nice approach and great explanation of multiple fundamental concepts. you keep producing interesting content, thanks

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

      Thanks a lot mate. Appreciate your comment!

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

    Once upon a time I was testing my grid trading strategy, and I got my balance to be 100x as much as initial balance in a matter of one year. But if I move the starting point of a testing literally by one day, i got busted almost immediately.
    So you shouldn't be obsessed with optimization. It should be able to keep being on the flow no matter of the 'financial weather'.

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

      Good point, overfitting isn't a good idea always.

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

      Referring to that at the end of the video. For a bulletproof optimization you need a train test split. I have covered something very similar here:
      ruclips.net/video/mabCIr-a4HA/видео.html

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

      @@Algovibes I'm sorry for commenting before watching the full video.

  • @Niko-ie6dh
    @Niko-ie6dh Год назад +1

    does the cross join and then loop over the dataframe way have a performance benefit over the nested loop? Intuitively I would have iterated just over x and y in a nested for loop

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

    very interesting!

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

      Thanks for your feedback Bryan!

  • @eliotharreau7627
    @eliotharreau7627 9 месяцев назад

    Hi, how to make the same cartesien product with tree paramaters x y z , because the merge function only accept two parameters ? Thank you

  • @kobiyobi629
    @kobiyobi629 4 месяца назад

    Could you explain how to use tensor flow to use GPU power when you have many more parameters

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

    What is the probabilty that optimized parametrs will bring profite in the future trading? The probability is very low, because you a looking for a best parametr using past data, but not checking, how this parametrs works on the future data! It is much more interesting to listen about forward testing, not about backtesting!

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

      You repeated exactly what I said in the video. I have content on that as well - Just watch all my videos and you will get a detailed and holistic view.
      Let me know if you need anything!

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

      If you have access to the "future data" then you don't need a trading strategy. Unfortunately google doesn't provide any links to future stock prices.

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

    Would a nested for loop work the same way as the cartesian product method, in the case of optimizing for 2 parameters?

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

      Also possible to solve this with a Nested loop but I highly recommend using the cartesian product/cross join here.

  • @Leonhard-Euler
    @Leonhard-Euler Год назад +1

    One point:
    You should check the period for sma_1 is less than that for sma_2

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

      Not necessarily as I wanted to test both sides but definitely an option.

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

    Could we please have a video about support and resistance level detection in python for bitcoin?

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

      Cool suggestion! Thanks a lot

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

    Thanks Bro, How to detect support and resistance using python?

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

      Interesting topic. Thanks for the suggestion!

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

      ​@@Algovibes Thanks for reply. Please make the code as simple as you can😇

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

    From a coding perspective, have you ever tried list comprehension for the conditional looping logic? I'm taking an online python course and they suggest "pythonic" way of coding. Their recommendation is centered around dealing with very large datasets. Just wondering whether you think there's a material benefit switching styles for this specific case of trading labels.

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

      Wouldn't make sense here at all. But yes I am a big time user of list comprehensions :-)

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

      @@Algovibes Thanks for replying. Will keep a look out for instances where you use list comprehension. 👍 Lots to learn 🫡

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

    Does it need to outperform the underlying vehicle to be viable?

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

      No definitely not. I am just referring to the interesting result that no matter which values you are passing you never outperform the asset itself over the long term (at least Apple). Interestingly this is not true for assets with a rather bad performance (e.g. MMM).
      There is much more to be considered: Exposure Time, Volatility, Max Drawdown, turnover and trading costs.

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

      @@Algovibes just curious. Cuz I always hear people talking about whether it does or doesn't. Drawdown is another term that lacks intuitive-ness for me too. Thanks.

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

      @@Algovibes would be fun to use volume as an indicator to determine how likely your trade would go through. For Apple it might not be an issue but this is another dimension of a full optimisation strategy.

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

      @@Algovibes this type of strategy should work much better for cyclical stocks like energy companies.

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

      I took algovibes' code and did a quick test on XOM to test this idea. To save time I only examined sma's from 10 to 50. Buy and hold had profit of 1.664 and the sma strategy produced a profit of 2.180 so it can (not necessarily will) work better on cyclical stocks.

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

    don't take AAPL, bet something wavy instead, like efs - TLT, HYG, JNK. SPY is not "wavy" but still a tiny bit outperform "buy and hold". Need something volatile but horizontal to outperform growing monsters.

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

      poor GDX goes like chupa-chups. I do not see sense for n > 75-100 (edit: well 100... )

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

      @@ageens 😄

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

      Energy stocks are perfect for this type of strategy.

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

    try vectorbt

  • @ko-prometheus
    @ko-prometheus Год назад +2

    ☢☢☢☢☢

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

      Thx for watching Konstantin! :)

  • @blasdelezo8396
    @blasdelezo8396 11 месяцев назад

    Its better to use final = final[final.sma_1 < final.sma_2]