Automated Candlestick Strategy in Python | testing the shooting star

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

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

  • @turugasairam2886
    @turugasairam2886 9 месяцев назад +1

    Thanks!

  • @turugasairam2886
    @turugasairam2886 9 месяцев назад +1

    Thanks for sharing. I like the clarity with which you explain. Thanks a lot.

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

      Thank you for your support, and for your comment it's nice to know that this content is of help.

  • @marceloferreira950
    @marceloferreira950 3 года назад +5

    Hi, very nice work. Just one thing, in the function mytarget, the last 4 rows of dataframe became nan, because range(0,lenght-3-1). If we put this on realtime the most recent values are nan.
    You use rsi, try use 3 EMA’s. 3, 6 and 9, if the 3 EMA its above 6 and 9 EMA we are in a uptrend for example. Continue with nice work

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

      Hi, thank you for your feedback, I see what you mean. In fact I have tried the 3 moving averages before (not in video) it also gives good information. I will try to include it in future videos... (thank you for the idea :) )

  • @Leo-cw6dr
    @Leo-cw6dr 3 года назад +3

    Thank you for sharing!! really helpful! Have Been struggling to code candlestick patterns for a while,!

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

    I am following your videos regularly, and other youtube channels, more or less many are teaching the same, basing on pattrens and moving averages, could you able to do price action trading only, with out using any indicator, how will you spot up trend, down trend and sideways, impulse move and correction, how to take trade in a time frame, with respect to higher time frame.
    Please make a video on price action, no one is doing on this, are they feeling difficult or they don't know ?

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

      Hi, price action is powerful I agree, but there are a lot of ideas to study, did you mean something like these videos:
      ruclips.net/video/oyuyeYi_7rw/видео.html
      ruclips.net/video/2Q_qXmNcsZw/видео.html
      ruclips.net/video/b5m7BZAHysk/видео.html
      or you have something more specific in mind?

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

      @@CodeTradingCafe
      yes my friend, I don't trust and even you might also know about, all the indicators are lagging in nature, so only through price action, top down multi time frame analsys, will give better results, with optimum risk to reward , so that's why I am requesting you to make a video to see price action kind of live trade using algo python code.
      I searched many youtube channels, no one ever done it, this could be a great video if you can do it, many will instantly follow 10 folds.
      just think about it
      have a good day

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

    it's alright the point of the shooting star is that you should take into account the candles before you kinda do it with the RSI, the problem is that RSI is less precise although 750 failed but 756 was correct.
    If you notice the shooting star in the false positive example correctly predict the "next" bar.
    Sure enough if you put lower TP and lower SL you may convert more candles in less false.
    instead of checking for a trend the algo should check for the next 1 2 bars and then close the position not at TP but TP based on timing.
    In a sense would be profitable if you calculate in real time around "power hour" or at almost closing but not at close directly because the order will be executed the morning after .
    The closing and TP should be at market - if reaches TP and at "almost closing" on day n+2

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

      Hello, you are right in fact it's frustrating that so many good signals result in loosing trades just because of TP SL methods, I should revise these differently, a time based trade seem interesting to try.

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

      @@CodeTradingCafe Yeah, you may create an histogram function using the dictionary to allocate frequecy based on the aplitude of the shooting star.
      an example if the shooting star's tail is over 2.00 to 2.25 the body check if the next candle is positive and trying to guess based on the Shooting star what would be the next candle.
      Generally if you have a short candle the next one will be a short candle.
      If it is so you can use various type of shooting star as Key and the frequency as values and plot then an histogram that checks the distribution. once is done you can use the most frequent shooting start parameters to check how many times the next candle is positive or negative and in what magnitude simply looping the selected key recording the different values (which will be the next candle)
      def x (s):
      for s in graph:
      if s == 2.25 to 2.5:
      return s[key] = [next_candle]
      else:
      xxxxxxxxxxxxx
      somethign like this with ofcourse the right sintax and the right variables...
      but in short should be able to return a key correspondent to the shooting star selected and a list with all the next candle.
      d = {shootingstar2.25to2.5 : [+3, +4, +3 etc.]} then plot an histogram to check the frequency
      In that case you have a "normal distribution" or a gaussian curve.
      it's a lot of data cleaning in reality, but in this case you are able to filter based on the most likely event after the shooting star.
      If the distribution is not "normal" means the pattern is random for that asset and therefore you cannot use it and Technical Analysis is wrong. It improves odds dramatically

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

      I probably see what you mean, I would do it differently, I woul plot the distribution of the candle ratios when the next candle is in the same direction... No data cleaning just plotting what we need, meaning for every candle where the next candle is of the same direction just put the ratios of the candle wicks and body into histograms.

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

    Excellent explanation. Have made any bot for indian share market?

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

      Thank you for your comment, not specifically however you can use the same algorithms explained here for Indian shares or any other market I believe these methods are standard everywhere.
      Good luck

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

    i am doing scalping by using 1min candle at certain time, so at that particular time I want to place sell and buy order for the previous one min candle high and low, it is possible to write code for this

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

      Hi, yes of course but you will have to include the time column into your coding, pandas has this feature already.

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

      @@CodeTradingCafe thanks for your reply, if possible make one video for this

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

      @@samraj46 I will it goes along with multi timeframe trading need to use date time, but it will take some time.

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

      Hello, did u manage to do this? I'm looking for the same exact thing.

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

      Actually rereading the comments I realized this is easier than I thought, it can be done using backtesting.py package just check my Rayner Teo video I used this feature already like putting delayed orders at some levels (min and max of previous candle in this case). I will be checking a strategy with this feature but it is going to be a while currently on a different track.

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

    very nice work! It would be nice to optimize the parameters through a routine to find the best winning settings.

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

      It's possible taking into account the algo might discover a different shape as well like hammer or doji in this case.
      Edit: actually it might be a good idea for a new video, like let the algo find the best winning candle shape... will think about it

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

    Great video! Thank you!

  • @user-je3yw5lu4v
    @user-je3yw5lu4v 3 года назад +3

    Talib has functions for candlestick pattern recognition but you didn't used it ?

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

      I am not aware of it, I will look into it and see what it does

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

      But I usually prefer to know what's happening inside the function just in case it might give false signals

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

      @@CodeTradingCafe just my humble opinion. I tried talib but not able to detect shooting star's hourly candle and I searched google for an answer and found your video. Clear and precise explanations. Will try out your codes. By the way, do u have website or do u book on python TA for candlesticks.

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

      Thank you for your comment, I honestly found pandas ta very easy to use I might do another video just showing the features (simply calling indicators functions) if you find it useful. If you get in trouble with pandas ta let me know I might be of help.
      Edit: no website unfortunately my time is squeezed, books yes (in radiation physics :) )

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

    nice contribution and very well explained , thank you
    can you share the code please as some of the code is not visable (line 7)

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

      Hi, thanks, the Jupyter notebook file is shared you can download it from the link in the description, hope it helps.

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

    Interesting work! I've reached 25.5% accuracy with this method, so it might be not a good idea for stock I did analyze.

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

      Hey thank you for sharing your results. Actually you might need to optimize parameters for each stock, and back and forward test to make sure results are robust. But yes it needs optimization first.

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

    I really like your channel and it is really useful. Thank you for sharing your experience 😁

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

      Thanks you for your support, I am glad the videos are of help

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

    Best video on Candlestick strategy + RSI on RUclips & any opensource platform.
    Interested to contact you personally regarding some strategy improvisation.

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

      Thanks, I am happy you liked it, if you want for further contact you can drop an email, I will be happy to help as much as I can

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

      How to backtest this strategy using Backtesting lib in python ? vectorbt is also a good alternative.

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

      @@SP-db6sh I m not familiar with backtesting libraries in Python (maybe I should start having a look at these) but here backtesting would be a trap! It will definitely provide good results because we are backtesting on the same data we used for tuning our parameters, so our model has already something of the data in memory. The correct way to test here is to run automated trades on a demo account, this way you would be testing on new data, the only problem is that it will take time, I would say at least 6-8 month to have a reliable result, since we are using daily candles. (Of course this time drops down if we try a model for the 4 hours candles instead)

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

      @@CodeTradingCafe which is your email, please?

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

      Hello it's in the "about" section of this channel

  • @Jamil.francis
    @Jamil.francis 3 года назад +3

    Valuable secrets.. thanks bro

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

    19:00

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

    Great video Sir

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

    Hi trading code. There is a way to contact you in private to speak about trading collaboration?

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

      Hi, saw your channel nice intro, my email is in the about page of this channel. Let me know if you have problems finding it.

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

    Hi, There seems to be something wrong with the provided code file. It seems to be all mixed up. Would appreciate if this could be rectified.

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

      Hi thank you for your comment, it's a Jupyter notebook file, did you try to open it using a different interface? (It has to be Jupyter)

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

      @@CodeTradingCafe It works after copying the file as it is into my folder. I use VScode and was copying the content of the file from notepad++ into a new file in VScode. Somehow it does not identify the file that way. Thanks!!

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

      @@BITRUN I see thank you for your feedback, and good luck!

  • @HarpreetSingh-ps9rx
    @HarpreetSingh-ps9rx 2 года назад +1

    Brilliant videos

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

    why you do all your strateies in large time frame like the daily timeframe? if you use a smaller timeframe you will get more signals and that mean more profit? if the strategy is correct, of course it is harder but is it correct?

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

      Hi it's much easier on large timeframes, but I also have scalping videos recently it's more or less rewarding.

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

      @@CodeTradingCafe But if you trade D1 timeframe you will have to wait months to know if your strategy is working live.

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

      @@paulbrown5839 it's true depending on the strategy's you might try it with a small account trading on different currencies to increase trades number, you could get an idea in about 3 to 4 months.

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

    Could you add a volumen indicator?

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

      Yes it's possible, however I don't know exactly which strategy you have in mind...

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

      @@CodeTradingCafe I am thinking on replace the RSI or add to it, to confirm the trigger when there are an volume aceleración. Sounds good? How could be done?

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

      @@sergiomiguel1960 Yes if I understood correctly it's straight forward, we already have a column with the "volume" in the data, so if it's "high" enough we confirm a buy signal? what about the sell signal?

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

      @@CodeTradingCafe the idea is to use an indicator that shows the volume is increasing, is not enough to see the volume. The volume is high in comparative with?

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

    thank you for this video

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

    Thank you

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

    👍

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

    i love all your videos brother, nice content, thanks for the vide.. can you tell how can i code ORB with 2 candles inside the range & entry on any candle breaking out of the range
    ORB high
    ORB low
    condition1
    candle2 high < orb high and candle low > orb low
    enntry:
    condition 1 is true & price> orb high
    "place order"
    can you help me to code the condition1, lets say market opens @ 5pm EST then ORB high & LOW of 1st 5 min candle & in the condition1 , i want to consider next candle after 5 mins, if it is in the ORB range & then any candle breakouts then entry...
    plz.. plz help me to code this

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

      Hi thank you for your support, what is ORB? Sorry I must have missed this

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

      @@CodeTradingCafe Opening Range Breakout !!

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

      @@iamprashantjain it depends how many candles you need to consider to define your range, let's say 5 candles so you will find the max high and the min low among these candles these will be your range limit, then any candle exceeding these values up or down is the break out candle. I would think of it this way as a first attempt

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

      @@CodeTradingCafe I do the same but only issue is.. I can code ORB but not nth candle so I can compare high1 low1 to orbhigh & orblow..
      Can you enlighten taking code as example ??

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

      we can discuss this on remote too.. if that's feasible ?

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

    Nice

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

      Happy you liked it, good luck with your trading

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

    i encounter this error for the code below
    nan
    /usr/local/lib/python3.7/dist-packages/ipykernel_launcher.py:7: RuntimeWarning: invalid value encountered in long_scalars
    import sys
    trendId=2
    print(df[df['result']==trendId].result.count()/df[df['signal1']==trendId].signal1.count())
    df[ (df['result']!=trendId) & (df['signal1']==trendId) ] # false positives

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

      Hi check if you have any missing values in the data, sorry it's hard to debug remotely