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

  Рет қаралды 13,284

Algovibes

Algovibes

Күн бұрын

Пікірлер
@Estrav.Krastvich
@Estrav.Krastvich Жыл бұрын
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 Жыл бұрын
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!
@Algovibes
@Algovibes Жыл бұрын
Thank you very much!
@gianfrancosilvestri2155
@gianfrancosilvestri2155 Жыл бұрын
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 Жыл бұрын
this is so much fun to find combinations of SMAs which doe not make much sense but works very well.
@fudgenuggets405
@fudgenuggets405 Жыл бұрын
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 Жыл бұрын
Agreed! Be invited to check out my newest series. I am going more into details there.
@cooltraderf
@cooltraderf Жыл бұрын
This is really great. Very clean and concise code. Well done.
@Algovibes
@Algovibes Жыл бұрын
Thanks buddy! Be invited to check out my other stuff :-)
@k2icc
@k2icc Жыл бұрын
Great. It will be nice to expand as stated. Thanks.
@Algovibes
@Algovibes Жыл бұрын
Thanks for your feedback, highly appreciated!
@denniscarver9147
@denniscarver9147 Жыл бұрын
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
@Master_of_Chess_Shorts
@Master_of_Chess_Shorts Жыл бұрын
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!
@gianpaoloborrello
@gianpaoloborrello Жыл бұрын
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
@bryan-9742
@bryan-9742 Жыл бұрын
very interesting!
@Algovibes
@Algovibes Жыл бұрын
Thanks for your feedback Bryan!
@muggzzzzz
@muggzzzzz Жыл бұрын
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 Жыл бұрын
Good point, overfitting isn't a good idea always.
@Algovibes
@Algovibes Жыл бұрын
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: kzbin.info/www/bejne/o5LFdHyoYsZnfqM
@muggzzzzz
@muggzzzzz Жыл бұрын
@@Algovibes I'm sorry for commenting before watching the full video.
@Niko-ie6dh
@Niko-ie6dh Жыл бұрын
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
@vladvol855
@vladvol855 Жыл бұрын
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.
@eliotharreau7627
@eliotharreau7627 10 ай бұрын
Hi, how to make the same cartesien product with tree paramaters x y z , because the merge function only accept two parameters ? Thank you
@Leonhard-Euler
@Leonhard-Euler Жыл бұрын
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.
@kobiyobi629
@kobiyobi629 5 ай бұрын
Could you explain how to use tensor flow to use GPU power when you have many more parameters
@eugenelee9826
@eugenelee9826 Жыл бұрын
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.
@MohkKh
@MohkKh Жыл бұрын
Thanks Bro, How to detect support and resistance using python?
@Algovibes
@Algovibes Жыл бұрын
Interesting topic. Thanks for the suggestion!
@MohkKh
@MohkKh Жыл бұрын
​@@Algovibes Thanks for reply. Please make the code as simple as you can😇
@sweealamak628
@sweealamak628 Жыл бұрын
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 Жыл бұрын
@@Algovibes Thanks for replying. Will keep a look out for instances where you use list comprehension. 👍 Lots to learn 🫡
@mnmedipa9239
@mnmedipa9239 Жыл бұрын
Could we please have a video about support and resistance level detection in python for bitcoin?
@Algovibes
@Algovibes Жыл бұрын
Cool suggestion! Thanks a lot
@bigphab7205
@bigphab7205 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
try vectorbt
@ko-prometheus
@ko-prometheus Жыл бұрын
☢☢☢☢☢
@Algovibes
@Algovibes Жыл бұрын
Thx for watching Konstantin! :)
@blasdelezo8396
@blasdelezo8396 Жыл бұрын
Its better to use final = final[final.sma_1 < final.sma_2]
Portfolio Optimization with Python [Cryptocurrencies]
15:32
Algovibes
Рет қаралды 9 М.
How To Back-Test Strategies |  Python For Finance Ep.2
23:06
Richard Moglen
Рет қаралды 89 М.
Sliding Window Technique - Algorithmic Mental Models
36:45
Ryan Schachte
Рет қаралды 367 М.
Trailing Stop Backtest For Algorithmic Trading in Python
19:25
CodeTrading
Рет қаралды 15 М.