Automated Rayner Teo Bollinger Bands Strategy Optimized For High Return

Поділитися
Вставка
  • Опубліковано 4 лис 2024

КОМЕНТАРІ • 79

  • @MuhammadSRaniYah
    @MuhammadSRaniYah 2 роки тому +5

    I can only say “I love you and your videos!”

  • @jacekmikolajczyk6661
    @jacekmikolajczyk6661 2 роки тому +5

    Hi. I just watched all (38) CodeTrading videos. Very good presentation of the idea of ​​various strategies and their implementation in Python code. But the optimization in these presentations is all about manually sizing the parameters. Could you please present how to automate the process of searching for the optimal size of parameters.

    • @CodeTradingCafe
      @CodeTradingCafe  2 роки тому +7

      Hi, thank you for your support! true I didn't automate it, for 2 reasons ... Sometimes it's time consuming computing wise when you have more than 4 parameters... Second it only leads to overfiting meaning the algo finds the perfect combination that works for past data but unfortunately not for future data and this is really disappointing. Best is to find a set of parameters that 'makes sense' with some kind of logic behind. At least it's my experience.

  • @JuanLopez-xe5vf
    @JuanLopez-xe5vf 2 роки тому +4

    Nice video, I’ve been building something similar in backtrader. You could increase your trades by running over a larger set of symbols. Ie all futures, cryptos, ftse etc. it’s actually quite interesting to see the differences between markets. I forward test in 12 month intervals to validate robustness of parameters to minimise overfitting. Anyway just some ideas, keep up the good work.

    • @CodeTradingCafe
      @CodeTradingCafe  2 роки тому +1

      Thanks for sharing, yes the best is to decrease risk and test on different markets. Good luck!

  • @henson2k
    @henson2k Рік тому +2

    Thank you for videos! How would you define choppy market?

    • @CodeTradingCafe
      @CodeTradingCafe  Рік тому +2

      Good question ! Probably fitting a line on the last N candles the slope has to be close to zero and the ATR above a fixed limit, the parameters will depend on the asset and the timeframe.

  • @MM88HI
    @MM88HI Рік тому +1

    Thank you for your hard work! Is it possible to show how to change the index that Backtrading uses from integer to date. It would be helpful to line up what Backtrading executed to actual dates.

    • @CodeTradingCafe
      @CodeTradingCafe  Рік тому

      Thank you for your support, I actually did it in one of my previous videos, but shame on me I am not able to remember which one, I only remember I did it so we can compute the Sharpe ratio for the backtesting.

    • @MM88HI
      @MM88HI Рік тому +1

      @@CodeTradingCafe thanks! Lol I guess I need to catch up with you other videos then. Looking forward to watching more of them today.

  • @TUFGM
    @TUFGM 2 роки тому +4

    Seria possível fazer uma (IA) que analisasse o gráfico e pudesse prever a continuidade do movimento?

    • @CodeTradingCafe
      @CodeTradingCafe  2 роки тому +1

      Hi I did something close to your description it's a video about channel detection you can do it by checking the slope of the fits

  • @jimparsons6803
    @jimparsons6803 Рік тому +1

    My thanks for the clip. I don't recall whether or not which version of Python is used? Just started learning Python a few days back. The differences from one edition to another can be a little surprising and unexpected.

    • @CodeTradingCafe
      @CodeTradingCafe  Рік тому

      Hi, thank you for your support. I have 3 python versions on my system I don't recap which one I used, I usually hover between 3.8 and 3.10, I don't think it makes any difference for the content shown in this video. Good luck!

  • @jroche1832
    @jroche1832 5 місяців тому

    excellent video thank you. Question, how do you buy on margin? I know you need a margin account but how do you enter a trade with specific margin like 1:5?

    • @CodeTradingCafe
      @CodeTradingCafe  4 місяці тому

      Hi, actually when you setup your account you need to specify the account leverage or margin, then it's fixed for all the trades you open through that account. This is why in the backtest it's a constant parameter in the function of the backtester.

  • @Ravi-ln7hy
    @Ravi-ln7hy 2 роки тому +2

    Nice video... Is there a automated way to plot HH, HL, LL, LH with python...?

    • @CodeTradingCafe
      @CodeTradingCafe  2 роки тому +3

      Thank you for your support, yes there is a way to select points/values and plot these, if I understand your question correctly, this video might be helpful ua-cam.com/video/phy57DZOIwc/v-deo.html
      Good luck

    • @Ravi-ln7hy
      @Ravi-ln7hy 2 роки тому

      @@CodeTradingCafe yes it's somewhat closer... I am looking to create something like this... I am not sure if it is correct... # fig.add_trace(go.Scatter(x=dfpl.index, y=dfpl.HH, mode='lines', name='HH'))
      # fig.add_trace(go.Scatter(x=dfpl.index, y=dfpl.LL, mode='lines', name='LL'))
      # fig.add_trace(go.Scatter(x=dfpl.index, y=dfpl.LH, mode='lines', name='LH'))
      # fig.add_trace(go.Scatter(x=dfpl.index, y=dfpl.LL, mode='lines', name='LL'))
      something like this...
      forexbee.co/wp-content/uploads/2022/01/Screenshot-572-1-760x417.png

  • @ZeroNonesense
    @ZeroNonesense Рік тому +2

    Something is off, tried running on AAPL for 2015-01-01 until 2023-01-21 and the return % is negative. The strategy needs further optimization.

    • @CodeTradingCafe
      @CodeTradingCafe  Рік тому

      Hi, thank you for your feedback, did you use the daily timeframe?

    • @ZeroNonesense
      @ZeroNonesense Рік тому +1

      @@CodeTradingCafe Yes, daily. Did not modify your code at all. I have my own version with some minor changes, however the win ratio is a little higher than 50%. By the way, I made a trading bot that works with Robinhood API, but after running it for about a month last year, I decided to switch it off, the results were 50/50. So now I am looking for different strategies, and came across your videos.

    • @CodeTradingCafe
      @CodeTradingCafe  Рік тому +1

      There are many winning strategies but you have to find a low commissions broker/type of account. And yes I think the parameters should be optimized for the strategy in the video

  • @jdf2159
    @jdf2159 2 роки тому +2

    Can I change the timeframe from daily chart to 1 minute chart?

    • @CodeTradingCafe
      @CodeTradingCafe  2 роки тому +1

      Hi I don't think it's going to work, that's huge difference!

  • @jroche1832
    @jroche1832 5 місяців тому

    What is interesting is that this model relies on margin without which you under perform B&H. With margin you expose yourself to a roller coaster of panic as every dollar loss is multiplied. Few can withstand that kind of pain.

    • @CodeTradingCafe
      @CodeTradingCafe  4 місяці тому

      I agree it's not realistically tradable, on the B and H matter, it's really hard to find a strategy that beats BH for long term uptrending stocks like apple, amazon, microsoft, gold ... however BH is easily discarded on ranging or downtrending assets.

  • @thinketh2408
    @thinketh2408 2 роки тому +2

    thanks

  • @Krisler12
    @Krisler12 2 роки тому +10

    Drawdown of -95% or -45% or even -20-25% is inacceptable. Imagine you put $100.000 cash and after a while suddenly you see -$50.000, even -$20.000 it's a lot.
    Of course it gives to you +30.000% but this is just because you tested it on index funds or stocks and these have mostly an uptrend. Try to see how it works when there is a lot of variation and volatility like Forex scalping or anything thing else that is not mostly in uptrend.

    • @CodeTradingCafe
      @CodeTradingCafe  2 роки тому +2

      Yes it's only shown for demo purpose only. First I would decrease leverage and have a steady curve up. Actually have you seen the first video of the Bollinger bands strategy? It has no drawdown. Let me know what you think.

    • @Krisler12
      @Krisler12 2 роки тому +7

      I have seen all your videos already but I have just seen once more that one you are talking about. -28% drawdown is HUGE.
      Second, it is wrong to optimize parameters because it will find best settings for already known data but it will fail on new data because it is like AI it is optimized for what it already knows and trying to predict the future based on past data is wrong just because data doesn't repeat, it is different, the future data is different than the past data, that's why it is not working.
      Also, just two or three trades it is not enough, it must be more than 500 trades let's say at minimum because in real life it will do a lot of trades.
      Also, index funds or stocks have mostly uptrends and very few downtrends which means that there is no variation, no volatility and it will fail big when the economic situation is bad, in fact when it meets the real fluctuations and volatility. You should choose for testing assets with very high volatility and fluctuations which are very hard to predict and to trade and where there isn't any clear trend up or down. For this I think 1 minute data is very good which also allows you to do a lot of trades to see how it works in real life and in hard to predict conditions because these conditions appears even in a clear trend and bland situation and when they appear they will destroy your strategy if it is not prepared for them.
      Also, try to add a trailing stop to see how it works.
      Expecting a new vide from you on the subject! 🤗

    • @sChaikovsky
      @sChaikovsky 2 роки тому +1

      @@Krisler12 you said that using past data to predict future is wrong because the future will not repeat. So my question to you is, what is the best strategy to trade? Where can I get profitable trading strategy? Or what can I do to trade profitably if this kind of approach or AI do not work.

    • @Krisler12
      @Krisler12 2 роки тому +2

      I don't know. If someone will find the best way to solve this problem he or she will be a billionaire and the richest man in the world. I think just using a more general strategy that could work on many assets and a trailing stop and also a good money management strategy could somehow give a good strategy.

    • @CodeTradingCafe
      @CodeTradingCafe  2 роки тому +3

      @@Krisler12 in my experience Real algos achieve 8% to 15% max per year, we're not talking leverage because it's not a good idea to increase risk. Some years returns are higher but that's just luck, normal automated systems are around 10% a year on average. I have discussed this with a real trading and investment company and this is the reality. Now other trading forms like high frequency or having access to restricted data can bring more power to the algorithm and this is where it gets interesting, but the data is restricted by law and money (have to be a certain type of registered company to ask access to advanced market data and you pay a lot for it annually). That being said it's still fun to try algos around, I tried recurrent neural networks recently I will post the code in a video... soon

  • @easwaraero7888
    @easwaraero7888 Рік тому +2

    hai sir , can you do robo for IQ OPTION / OLYMP TRADE like binary option concepts?

    • @CodeTradingCafe
      @CodeTradingCafe  Рік тому

      Hi you can directly adapt this code for any market you desire. Good luck!
      Edit: check my last video for building a trading bot.

    • @easwaraero7888
      @easwaraero7888 Рік тому

      @@CodeTradingCafe can i contact you sir? please

    • @CodeTradingCafe
      @CodeTradingCafe  Рік тому

      Hi, unfortunately I can't take any developments at the moment, lots of projects going on. But you can make it just walk through the videos.

    • @easwaraero7888
      @easwaraero7888 Рік тому

      @@CodeTradingCafe any other developers can u recommend,

    • @easwaraero7888
      @easwaraero7888 Рік тому

      @@CodeTradingCafe thanks for your responce

  • @michaelmcnaughton1535
    @michaelmcnaughton1535 5 місяців тому

    Yes but does it translate forward on the data not seen by the training/optimization. Don’t believe so.

    • @CodeTradingCafe
      @CodeTradingCafe  5 місяців тому

      It's harder to make it work for low timeframes, but for some reason every strategy I tried on the daily time frame worked well but it's slow, one trade per month so we need to run on more assets ... so more money is needed in the account.

  • @melstadevosyan
    @melstadevosyan Рік тому +1

    so basically you gain money when trend is going up and losing when its going down, if we find some way to not los money (buy when its still down trend) we will have higher wr for sure

    • @CodeTradingCafe
      @CodeTradingCafe  Рік тому

      Hi, thanks for sharing. As it is, yes you are right for the algo deals well with one trend direction. You can also have another algo tuned for downtrends and the 2 algos running together might be a good hybrid solution.

  • @daveb4446
    @daveb4446 Рік тому +1

    15:1 margins and no fees included. So it’s purely hypothetical and not using real world conditions

    • @CodeTradingCafe
      @CodeTradingCafe  Рік тому

      I agree it's not an absolute estimate but it allows me to compare strategies and indicators together at some point we can retest a strategy if it looks promising adding commissions. Also trade management is very simple here it can be improved as well (this part I find fascinating)

  • @1ndraNugraha
    @1ndraNugraha 11 місяців тому +1

    where is the code for mt5?

    • @CodeTradingCafe
      @CodeTradingCafe  11 місяців тому

      Sorry coding only in python these days.

  • @arunavadatta7734
    @arunavadatta7734 2 роки тому +2

    it's just in a theory ..............practical case is totally different

    • @CodeTradingCafe
      @CodeTradingCafe  2 роки тому +1

      Yes this one is not advised for real trading, just a python exercise

  • @newbienoob1
    @newbienoob1 2 роки тому +2

    Thank you sir the problem is u r using large timr data we want to get rich fast while sleeping hh😂😅 (as you said in 9ne of your videos )

    • @CodeTradingCafe
      @CodeTradingCafe  2 роки тому +1

      I must make a video about this becoming rich fast issue 🙂 I get this question a lot as well.

    • @newbienoob1
      @newbienoob1 2 роки тому +1

      @@CodeTradingCafe we know sir hhh just jocking make a video about getting rich while sleeping 😂😂😂

    • @newbienoob1
      @newbienoob1 2 роки тому +1

      Getting rich in our dreams maybe 😂😂😂

    • @CodeTradingCafe
      @CodeTradingCafe  2 роки тому +1

      Well you can still make money while sleeping but not enough to be rich... Rich like buying a hotel a boat and a supercar, trading makes 20 percent return per year so it's limited. But again you can make some money out of it.

  • @kadourkadouri3505
    @kadourkadouri3505 2 роки тому +3

    Unsurprisingly, the strat lost money during COVID outbreak (black swan event).

    • @CodeTradingCafe
      @CodeTradingCafe  2 роки тому

      I didn't notice the link, might be true! Thank you for your comment

  • @btoiscool
    @btoiscool 25 днів тому

    Are we just going to slide right past that drawdown 😂

    • @CodeTradingCafe
      @CodeTradingCafe  21 день тому

      yep :) this is mainly what happens when greed pushes leverage up.

  • @crystalwatertherapy
    @crystalwatertherapy Рік тому

    inspiring videos, BRAVO

  • @Seeker_of_sense
    @Seeker_of_sense Рік тому +1

    Very misleading. This market is already in a strong uptrend. It's hard not to make money.

    • @CodeTradingCafe
      @CodeTradingCafe  Рік тому

      It's not misleading if you already know the strategy works in trending markets, other strategies work in ranging markets... there is no single strategy that works in all types of markets. But yes I understand that it can't be applied blindly to all circumstances, it simply wouldn't work. However the Bollinger entry trick does bring an advantage in most cases.

  • @geeamuza2375
    @geeamuza2375 2 роки тому +2

    Hi @codetrading can you show how to use it on Crypto exchange like coinbase or other please. thank you for the videos

    • @CodeTradingCafe
      @CodeTradingCafe  2 роки тому +1

      Hi it's possible only if the platform has python API, like binance for example for the rest I have to check

    • @geeamuza2375
      @geeamuza2375 2 роки тому

      @@CodeTradingCafe Thank you do have video to show how to use on binance please. Much appreciated

    • @1cBoris
      @1cBoris 2 роки тому +1

      Hi you can use ccxt library

  • @lennard4454
    @lennard4454 6 місяців тому +1

    4:15 this isn't good practise. one should not use python lists and slow for loops but perform the operations directly on the dataframe:
    df['EMA_SIG'] = np.nan
    df.loc[df.EMA_1 < df.EMA_2, 'EMA_SIG'] = SIG_BEAR
    df.loc[df.EMA_1 > df.EMA_2, 'EMA_SIG'] = SIG_BULL

    • @CodeTradingCafe
      @CodeTradingCafe  6 місяців тому +1

      Hi, thank you, I agree vectorized approach is more efficient.

  • @sspmetal
    @sspmetal 2 роки тому +2

    Try this code on h1 timeframe

    • @CodeTradingCafe
      @CodeTradingCafe  2 роки тому +1

      Someone did they told me it's highly profitable!