Trading Strategy implemented in Python based on ST momentum and TSL

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 ธ.ค. 2024

ความคิดเห็น • 80

  • @endsemister
    @endsemister 10 หลายเดือนก่อน +5

    ΔQ=ΔU+W --> First law of Thermodynamics
    The change in internal energy of a system is equal to the heat added to the system plus the work done by or on the system.

    • @Algovibes
      @Algovibes  10 หลายเดือนก่อน +2

      Boss, you catched the gimmick. Pin 📌 for that my man

    • @endsemister
      @endsemister 10 หลายเดือนก่อน

      @@Algovibes yess...

  • @daniel4178
    @daniel4178 10 หลายเดือนก่อน +6

    Amazing video! Would love to see the vectorized version you mentioned in the video

    • @Algovibes
      @Algovibes  10 หลายเดือนก่อน

      Thx mate. Sure thing, thx for your feedback!

    • @daniel4178
      @daniel4178 10 หลายเดือนก่อน

      @@Algovibes Thank you for posting all these very informative videos for free. You inspire me to try to follow your code and tinker with it. To this note, I wanted to ask you about two changes to the code that I though of (I am asking for confirmation bc I am a still noob at Python):
      1) Once we enter the position in the first if statement (where we set in_position = True), doesn't it make more sense to put a "continue" afterwards, so that we go straight to the next bar? Because currently we set the buy price at Open of t+1, but in the if statements immediately after we consider the row.Close, which still refer to t0, which may lead to some inconsistency in volatile days.
      2) This only for daily data for stocks: regarding selling, wouldn't it be more accurate to set the selling price equal to the trailing stop loss? For example, let's say the stop loss is triggered on Wednesday at 10 a.m. and the price keeps sliding; our if statement will check on Wednesday at close (4 p.m.) if the price is lower, and sell the stock the following morning. However, this is almost 1 day later than when the stop loss was originally triggered. With the selling price = trailing stop loss we would bypass this problem assuming that if the row.Close is less than the trailing stop, our exit price will be the trailing stop (executed some time during the trading hours).
      Sorry for the long text, and again the only reason I am asking is because I started tinkering with the code thanks to your great videos, and being still a beginner I am not certain if these solutions make sense.
      Thank you!

  • @Asparuh.Emilov
    @Asparuh.Emilov 6 หลายเดือนก่อน +1

    I am so grateful for the amazingly useful coding tips and tricks! Just one thing probably to consider is that the trailing stop should track the lows of the candles instead of their close, since in reality if the wick of candle hits the stop loss you would be out of the position.

    • @Algovibes
      @Algovibes  6 หลายเดือนก่อน

      thanks mate!

  • @dylankearns8822
    @dylankearns8822 9 หลายเดือนก่อน +2

    Would it be possible to make a video on how you would turn this into a live trading bot. The idea between backtest and live bot is a tad confusing to me!

    • @Algovibes
      @Algovibes  9 หลายเดือนก่อน

      Extremely interesting suggestion. Thanks!

  • @paweldmochowski4124
    @paweldmochowski4124 10 หลายเดือนก่อน +2

    Great tutorial! It's amazing how well You're able to explain both the code and the financial concepts!
    One point which I think woul be great to add at the end of Your videos is creating a function which would automaticaly search for the best variable combination (e.g. go through ebtry values from 1-5% together with dist values from 1-5% and find highest profits).
    That way we don't need to "play" with parameters but find the best possible combination yelding highest profits.
    Again, glad I found Your channel here.
    Looking forward to more videos - maybe showing strategies with known technical parameters (RSI, MA, etc...)?

    • @Algovibes
      @Algovibes  10 หลายเดือนก่อน

      Thanks my mate. Happy to read!
      I have covered that in past videos (Optimizing parameters) - be kindly invited to check my other stuff.

  • @anilmm2005
    @anilmm2005 10 หลายเดือนก่อน +5

    Long time coming.. one of great videos and would move to see vectorized approach in another upcoming video of tours 👍

    • @Algovibes
      @Algovibes  10 หลายเดือนก่อน +1

      Thank you for your feedback. Will see what I can do!

  • @SztucznaInteligencjaIA
    @SztucznaInteligencjaIA 10 หลายเดือนก่อน +2

    Great video as always! I think its not that hard to add AI feature and check all the combinations for TP/SL 0.5% till 10% changing gradually (0.5% , 10%) (0.6%, 10%) etc will be a few thousands of combinations. What is more I think we would have to do it on M1 frame or M5. What is during certain 1h period we hit both, SL and TP as well? Next its interesting to try this strategy adding limit orders as TP. Using perpetuals I pay 0.02% as commisions for limit orders what is game changer here, there is no point to buy BTC on spot.

    • @Algovibes
      @Algovibes  9 หลายเดือนก่อน

      Hi mate,
      thx a lot! Covered that in previous videos so be invited to check them out. You don't necessarily need AI but a simple brute force approach (or an algebraic one) will also do that job.

  • @Frdy12345
    @Frdy12345 10 หลายเดือนก่อน +2

    Thanks a lot, another clearly explained strategy and coding. I would like to see the vectorised one too.

    • @Algovibes
      @Algovibes  10 หลายเดือนก่อน +1

      Thank you mate. Will see what I can do!

  • @fpvmb
    @fpvmb 10 หลายเดือนก่อน +2

    Hey man love your videos but i keep getting the same error it says: 'DataFrame' object has no attribute 'interrows' it has the error on the line of 10:24 . Can you please help?

    • @ericp.5533
      @ericp.5533 10 หลายเดือนก่อน +1

      Its "iterrows"

    • @fpvmb
      @fpvmb 10 หลายเดือนก่อน +1

      @@ericp.5533 yhea i found out. Took my way to long🤣

    • @Algovibes
      @Algovibes  10 หลายเดือนก่อน +1

      happens to the best :-)

  • @elwinpietersz4531
    @elwinpietersz4531 9 หลายเดือนก่อน +1

    I started watching your videos. Just brilliant. Thanks you .

    • @Algovibes
      @Algovibes  9 หลายเดือนก่อน

      Thanks mate. Happy to have you on board :-)

  • @scientifictraders
    @scientifictraders 8 หลายเดือนก่อน +1

    You mentioned optimizing the code by vectorizing the rule-set. But you didn't mention any technique to quickly identify the optimum parameters. Rather than applying the laborious manual methods of a trial-and-error, or applying nested loops, what in your experience is the most efficient method to find the parameters that produce the highest return (ie: genetic algorithm, ML, etc.)? Have you made a video combining iterating a rule-set with various methods to find the highest return?

    • @Algovibes
      @Algovibes  8 หลายเดือนก่อน +1

      hi mate, yes I did a couple of months ago. Cheers!

  • @mikhailterterov2018
    @mikhailterterov2018 10 หลายเดือนก่อน +1

    Thanks for the video! Why do you check the stop condition with the closing price? It seems it should've been checked with Low in this case

    • @jalexisg
      @jalexisg 10 หลายเดือนก่อน

      Because Price changes every second, you are not checking the close price of the one hour candle after buy trigger, but the last price which is the one a second ago.

    • @Algovibes
      @Algovibes  10 หลายเดือนก่อน

      First of all thanks mate! Just copy pasting my answer from a previous comment:
      It's not a real "error" but rather a simplification. As @jalexisg pointed out in a real time setting (e.g. bot setup) you would consider the realtime price anyways. Anyhow I agree you can take the Low as a proxy to see whether the trailing stop loss was hit and take the trailing stop level as the exit.

  • @epo295
    @epo295 9 หลายเดือนก่อน +1

    Hey! Great video thank you so much! Would it awesome if we had a web app where we could plot our python code and signals into tradingviews lightweight charts?

    • @Algovibes
      @Algovibes  9 หลายเดือนก่อน +1

      Thanks mate. Appreciate you leaving a comment!

  • @tracywang1
    @tracywang1 10 หลายเดือนก่อน +1

    Great tutorial!
    Do you do any one strategy including both short and long?

    • @Algovibes
      @Algovibes  9 หลายเดือนก่อน

      Thanks a lot mate. Yep I have covered shorting in previous videos as well!

  • @Malik.omari2002
    @Malik.omari2002 10 หลายเดือนก่อน +1

    hi algovibes in one of your videos you talked about using Logistic Regression to get 51% accuracy over the market and i looked for that video every where and i can't find can you help me .

    • @Algovibes
      @Algovibes  9 หลายเดือนก่อน

      Quite some time ago. What you can try is simply browsing the channel looking for Logit regression. Let me know if you find something, otherwise I will take a look. cheers!

  • @pedroasadei
    @pedroasadei 10 หลายเดือนก่อน +1

    Great video as always my friend! Thanks a lot

    • @Algovibes
      @Algovibes  10 หลายเดือนก่อน

      Thanks for watching mate. Appreciate you leaving a comment :-)

  • @dallibabs
    @dallibabs 10 หลายเดือนก่อน +1

    I thought you had dropped your Dashboard tutorial.. is it available in the members area ?

    • @Algovibes
      @Algovibes  10 หลายเดือนก่อน

      Nah a deal is a deal. Deal was 2024 engagements, we landed at roughly 500 so it was not that close 🫣 I will think about uploading it to the member drive tho.

    • @dallibabs
      @dallibabs 10 หลายเดือนก่อน +1

      I'm back in the office by the end of this week. I'm going to sign up anyway. You deserve the sub just for all the knowledge I have gained from you. Thank you very much for your time, and effort putting these videos together.@@Algovibes

  • @VoltaireParis
    @VoltaireParis 10 หลายเดือนก่อน +1

    very interesting as usual !! thanks a lot

    • @Algovibes
      @Algovibes  10 หลายเดือนก่อน

      Awesome to get that from Voltaire personally 😁 Thx mate

  • @jitkadyan
    @jitkadyan 10 หลายเดือนก่อน +1

    sir now u not active on u tube , pls post video regularly ur video are very informative and practical

    • @Algovibes
      @Algovibes  10 หลายเดือนก่อน

      Hi mate, doing my best to post regularly but I cannot dedicate that much time into TH-cam currently. Thanks for your patience!

  • @bryan-9742
    @bryan-9742 10 หลายเดือนก่อน +1

    he's back!

    • @Algovibes
      @Algovibes  10 หลายเดือนก่อน +1

      He was never away :-) I just cannot dedicate that much time into TH-cam currently. Thanks for watching and your comment mate

    • @bryan-9742
      @bryan-9742 10 หลายเดือนก่อน +1

      @@Algovibes WELCOME BACK! Heres a challenge for. you. How would you apply a X to Y mapping (predictive features X to a return/price estimation conditional on X) with a Transformer using say Tensorflow/keras or Pytorch? Youd need to know how to positionally encode the features appropriately and elect the suitable standardization of the continuous feature variables (If you don't want to just rely on Layer Normalizaton). You'd also need to have some manner to assesses features to use in the X to Y mapping.

  • @bkomaki
    @bkomaki 10 หลายเดือนก่อน +1

    I could not find the python codes anywhere!

    • @Algovibes
      @Algovibes  10 หลายเดือนก่อน

      Be invited to become a channel member and get access to it!

  • @amitshewale1594
    @amitshewale1594 10 หลายเดือนก่อน +1

    Can you do some video showing maximum favourable and adverse excursion?

    • @Algovibes
      @Algovibes  10 หลายเดือนก่อน +1

      Interesting suggestion! Will see what I can do. Cheers mate

  • @csongi4444
    @csongi4444 10 หลายเดือนก่อน

    Hello. Can you help me please? Im getting this error: TypeError: As of 3.10, the *loop* parameter was removed from Queue() since it is no longer necessary. I don't found any solution.. please help me, im using google colab too

    • @arturKrzyzak
      @arturKrzyzak 9 หลายเดือนก่อน

      Ask chatgpt

  • @jean-francoislebroch9171
    @jean-francoislebroch9171 10 หลายเดือนก่อน +1

    Excellent

    • @Algovibes
      @Algovibes  10 หลายเดือนก่อน

      thx mate, happy to read!

  • @thecashlessgamer480
    @thecashlessgamer480 10 หลายเดือนก่อน +1

    amazing video, can you do one to build a volume breakout sort of strategy for equities please?

    • @Algovibes
      @Algovibes  9 หลายเดือนก่อน

      thanks buddy, will see what I can do. Appreciate the suggestion!

  • @BoHorror
    @BoHorror 10 หลายเดือนก่อน +1

    I have a strategy here, why dont you try using NEAT the evolutionary algorithim, have the 60 EMA , the 30 EMA and the 15 EMA, the gradient from the past 7 candles and position holding as input , output is buy , sell or close position so -1 , 0 ,1 and see what happens?

    • @Algovibes
      @Algovibes  10 หลายเดือนก่อน +1

      Hey Bo,
      thanks a lot for the suggestion! I also saw you left another one and noted that down. Cannot promise anything as I am currently quite swamped, anyhow appreciate the input a lot.

  • @atacanimsi
    @atacanimsi 10 หลายเดือนก่อน

    thanks for another great video but i think there is a small error, you should be checking your trailing sl against the low value of the subsequent candle not the close, which also applies to profit calculation too

    • @jalexisg
      @jalexisg 10 หลายเดือนก่อน

      It checks if in the last hour there’s an increase of 1%, once it buys you don’t mind either the low nor the close of the candle, but the last price, which in Binance it changes every second. So, the trailing stop can change any time while a rising trend.

    • @Algovibes
      @Algovibes  10 หลายเดือนก่อน +1

      Thanks mate! It's not a real "error" but rather a simplification. As @jalexisg pointed out in a real time setting (e.g. bot setup) you would consider the realtime price anyways. Anyhow I agree you can take the Low as a proxy to see whether the trailing stop loss was hit and take the trailing stop level as the exit.

  • @andrutowy
    @andrutowy 10 หลายเดือนก่อน +1

    Thank you very much for the content, appreciate it!

    • @Algovibes
      @Algovibes  10 หลายเดือนก่อน

      Appreciate you watching my man!

  • @franklinsharp1092
    @franklinsharp1092 10 หลายเดือนก่อน

    I try to use the python-binance library but due to the fact that i am in a banned country it print out failure even with vpn
    What should i do?

    • @bdcash
      @bdcash 10 หลายเดือนก่อน

      you could use yfinance instead for your data

    • @romerorg1
      @romerorg1 10 หลายเดือนก่อน

      I used a VPN. I think I used Germany as the source country.

  • @romerorg1
    @romerorg1 10 หลายเดือนก่อน +1

    Thanks for the video! Also, very much enjoying your Udemy course.

    • @Algovibes
      @Algovibes  10 หลายเดือนก่อน

      Hi mate, very happy to read. Thx!

  • @elu1
    @elu1 10 หลายเดือนก่อน +1

    Very nice!

    • @Algovibes
      @Algovibes  10 หลายเดือนก่อน

      Thank you mate!

  • @scalpingboy71
    @scalpingboy71 10 หลายเดือนก่อน +1

    Ottimo, bravissimo

    • @Algovibes
      @Algovibes  10 หลายเดือนก่อน

      Grazie Mille :-)

  • @yellowboat8773
    @yellowboat8773 5 หลายเดือนก่อน

    This is always going to male money in a bull market, though. The past history is perfect

  • @AyoOkeme
    @AyoOkeme 10 หลายเดือนก่อน +1

    Awesome

    • @Algovibes
      @Algovibes  10 หลายเดือนก่อน

      Thank you my man!

  • @siloquant
    @siloquant 10 หลายเดือนก่อน +1

    How do you come up with the number 0.0015 for trading cost? Is it included both slippage and commission? I think trading cost estimation for different timeframe, different assets and pct return and return in log space is very good topic to cover. Thanks for the good tutorial.

    • @siloquant
      @siloquant 10 หลายเดือนก่อน +1

      Over estimated trading cost can nullify possible good strategies and under estimated trading costs can also lead wrong conclusion on bad strategies, I think there must be some sweet spot for trading costs.

    • @Algovibes
      @Algovibes  10 หลายเดือนก่อน +1

      One trade is 0.075% (== 0.00075) -> Buying and selling is two times that with the note that BNB has to be the trading fee asset (which I am personally doing since its simply cheaper). Slippage is not included yet I would take an additional small proxy in for that.