Easy Crypto Trading: A Comprehensive Guide to VWAP Strategy in Python

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

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

  • @seeyee1184
    @seeyee1184 7 месяцев назад +2

    Hello, thank you for this simple yet very productive algorithmic trading example! I have noticed a clear pattern: the strategy performs well during a macro uptrend in Bitcoin but incurs most of its losses during a macro downtrend. Hence, it seems that adjusting the VWAP and EMA parameters in the example for the downtrend could potentially optimize profits during downtrends or, at the very least, minimize losses. Could you provide more hints or guidance on how to detect a larger downtrend more quickly? And then how to determine the right VWAP and EMA parameters during a wider downtrend? Thanks!

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

      Hi, thank you for your support. I think it would be good to build a model that trades only long, and another model that is adapted just for short positions. This way you have 2 sets of parameters so 2 models for different trends. For parameters optimization check this video: ruclips.net/video/IfoZaCGTJ_Q/видео.html

  • @kevinjohnson7072
    @kevinjohnson7072 2 года назад +6

    Hello CodeTrading!
    Thanks for showing Pandas TA and integrating it with the Backtesting package!
    KJ
    😎

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

      I like both tools, very straightforward and easy to apply and makes my code more elegant. Thank you for your comment!

  • @AMA-xi5vp
    @AMA-xi5vp 2 года назад +7

    best trading algorithm channel ever. I don't know if there are people as experts as the Bro here on the topic, just amazing. Hope you are planning to make an entire video series where people like me (even all of them in the comments) can learn through an explanation of each row of code. I know maybe is boring for you but I think people will love that. Anyway still thank you for sharing your knowledge with us.

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

      Thank you for your kind support, check this playlist, let me know if it's interesting.

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

      @@CodeTradingCafe can you show the code through which you can download a csv file on eth history on 15m timeframe?

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

      @@Dkaxxxq hi you can get the data from dukascopy also without a code just log in for free and use their web interface. Good luck!

  • @MrRahul15937
    @MrRahul15937 6 месяцев назад +2

    If we could add Elliott wave ideas or find scallop pattern ....
    Wave 1 and wave2 together can form scallop pattern, combining with above signals
    Thoughts only...

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

      Elliot Wave is on my to do list, for some reason I haven't coded it yet, I think I didn't find a full strategy to rely on.
      Thank you for your support.

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

    Interesting. I'm more into stocks rather the cryptos. It would be interesting testing the strategy with a bunch of stocks. Thanks man!

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

      Good idea, I will see maybe it can be done quickly, anyway I am also preparing a stock Bollinger bands strategy video... Next week maybe

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

      @@CodeTradingCafe Great! I'll be looking forward to watching those videos!

  • @apogounte8239
    @apogounte8239 8 месяцев назад +1

    Hey! As always nice work! Do you know how we can calculate the upper and lower band of the vwap? I do not think pandas ta library has it integrated

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

      Hi, thank you, the upper and lower bands are just the standard deviations of the VWAP so it's like VWAP+STD (for the upper) and VWAP-STD (for the lower), STD can be easily computed using normal pandas there is a function std() that you can apply on a slice of data (the VWAP column).

    • @apogounte8239
      @apogounte8239 8 месяцев назад

      @@CodeTradingCafe hi! i have tried several code variations, but i do not seem to get it right, as in the tradingview charts. the code i used is the following: df['rolling_vwap_std'] = df['vwap'].expanding().std()
      df['vwap_upperband'] = df['vwap'] + df['rolling_vwap_std'].
      I get the vwap using the library u r using on the video, which is correct. BUT the upper band is not the same. any help on your side would be appreciated

  • @Seldomtraveler
    @Seldomtraveler 10 месяцев назад +1

    Please combine with volume profile & VWAP

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

      It's a good idea to include volume, thank you.

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

    Hi, very intresting video :). Please where did you get the spreadsheet? Tnx

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

      You can get data from yfinance or dukascopy. Good luck!

  • @Asparuh.Emilov
    @Asparuh.Emilov Год назад +1

    I like your content, is useful to create a basic backtesting for the strategy. However keep in mind that you are taking all signals that appear immediately one after another, which might be misleading in a real case scenario where you would usually like to have just one entry per valid setup. This might change not only the performance of the strategy itself but also the entire behaviour of the system for different conditions. Other than this, thank you for the methodologies shared!

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

      Hi thank you for your comment. Just to be clear on this point, I allow one opened trade at a time so if a trade opens after a signal trigger no other trades can be opened until this trade is closed. sometimes I just remove this option just for fun or on purpose out of curiosity to see how it goes. Is this what you meant by "taking all signals"?

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

    thanks again. Do you have any videos that show how to automate the trading strategy please? ideally using bybit apis?

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

      Hi, I never used bybit apis, the thing is that each platform has a different set of libraries so you will have to go through their documentation.

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

      @@CodeTradingCafe ok no worries. Thanks. Have you covered any of the apis in your vids for crypto? I couldn’t seem to find any..only oanda

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

      @@preetipics Only Oanda so far just as an example because I had the code I have been using.

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

      @@CodeTradingCafe ok cool, thanks

  • @tankburn
    @tankburn 5 месяцев назад

    Hi great content! I wanted to know how your EMA length 100 looks like this. Mine doesn't pivot above and below like your one does in the graph/showcase on the second timestamp. Did you do anything special there that was not on the video?

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

      Hi, no nothing special for the EMA. Did you use the 15 min timeframe?

    • @tankburn
      @tankburn 5 месяцев назад +1

      @@CodeTradingCafe yes but I am using different data. Thanks for the reply, I will double check my strategy. I really enjoy your videos, please keep doing what you are doing :)

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

      I know it's frustrating, probably a small detail somewhere... hard to find sometimes

  • @MrRahul15937
    @MrRahul15937 6 месяцев назад +1

    Some time frame showing huge profits, some huge loss...
    I kept engulfing candle part commented.
    Need to thoroughly check various timeframe, various back candles....
    Also , may be we can filter signals only for US trading hours as it might be most active trading session.

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

      Hi, thank you for sharing. I agree limiting trading to the US market times is good, but also it depends on strategy and asset. Checking multi timeframes is also a great idea to confirm overall trend and entry signals, I was intending to make a video on this... since the time I promised :)

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

    Your videos are such a wealth of inspiration. Great content. Have you made a video about a possibility where the python bot could be able to chase a candlestick up and down, buying and selling in a period of seconds with high frequency trading? Without necessarily back testing ?

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

      Thank you for your comment, I haven't tried fast trading, but if you have a specific idea let me know this sounds interesting.

  • @p.r.385
    @p.r.385 2 года назад +1

    very surprising results. looks like a market filter could help to improve the strategy in the last year, which was rather choppy, downwards and sideways.

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

      Yes surprisingly good, I think there is a potential here I will definitely revisit in a future video

  • @leobike-1920
    @leobike-1920 9 месяцев назад

    Do you think trailing SL to minimize our loss ?
    Btw, may i undertand what do you mean in TotalSignal function with comment "#careful backcandles used previous cell" ?

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

      Hi, the comment careful.... means that the backcandles parameter was used in the previous cells so it already has a value to be considered before you change it. And a SL might be a good idea but there is only one way to find out.

  • @jonedow2381
    @jonedow2381 10 месяцев назад +1

    Very well made content and strategy. Would be even more useful if we can optimise the parameters for the given timeframes

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

      Thank you for your support, I recently uploaded a video on optimization I think we can use it for any strategy.

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

    great video, where you get the data file from?

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

      Yfinance or dukascopy mainly. Thanks for the comment.

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

    I think this strategy should be tested in sell-only mode to determenate, is it sutible for bearish market. If i do it, i'll share the result under this comment.
    Thank you for inspiration😁

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

    Hello man! Thank you very much, do you know where I can get the same time frame data for ethereum, solana, cardano ... would appreciate

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

      Hi, dukascopy is a good source they have a nice interface.

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

      @@CodeTradingCafe just tried and for what I have noticed I can’t download the data with a timeframe 15min as you had in this video. Btw what are the numbers you recommend in the myclosedistance variable for ethereum/solana/cardano? Thanks once again!!

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

      @@CodeTradingCafe found how to extract! thanks man! meanwhile would appreciate the other question I have made regarding the myclosedistance variable

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

      The distances difficult to say you have to try it and correct along.

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

    Your content is fantastic and helps me a lot. Thank you very much.
    For this tutorial, as you mentioned at the end that the current strategy is not dynamic. So, do you plan to make it more dynamic and share it to us? I think we all would love to see how you make the strategy more dynamic or how to optimize it in your own way.

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

      Thank you for your support! Good point regarding optimization, it's the most time consuming task actually I always try to keep videos as short as possible, I will think of something that fits into a RUclips video. Good luck!

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

      @@CodeTradingCafe Looking forward to your video. Thank you in advance.

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

      @@CodeTradingCafe this would be massively helpful if you could pls :)

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

    thankyou so much for creating such a valuable content. really appreciate your time and effort to educate

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

      Thank you again for your support, much appreciated.

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

    The real money maker would be to combine this strategy with another which is profitable in a bear market

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

      It's surprisingly profitable for a simple approach I will definitely revisit and improve upon.

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

    To those who are about to waste their time with this video:
    BTC trading isn't free. You have to pay 15/1000 th of your entry value as commission, and there is also the spread. That's almost a quarter of how much BTC moves at US open.

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

      Hey teenspirit, I am not sure why is it a waste of time, unless you are looking for a money making machine type of programs, everyone knows that you need to add spread and trading cost, however before adding those you also need to test a bare strategy/indicator to see if it's optimized properly and to compare it with other previously tested indicators. I do this in my day to day job and I can tell you for those learning algorithmic trading this is not a waste of time, however for those who think that you can run a program and buy a new house next week ... Good luck!

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

    hi, where I can get the input data on an ongoing basis (for ej. every 5 minutes of XBTUSD) thanks in advance :)

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

      Hi, the easiest is yfinance, but for live trading also your broker might have an API. Check my last video for broker API example.

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

      ... yfinance can also give you live price

  • @3rdpartylegends
    @3rdpartylegends 2 года назад +1

    Hi There are two technical analysis libraries present in python i.e (ta and pandas_ta) both of them have VWAP fuction and they both give Different results on similar data and time frame so which is better

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

      Hi I had same problem with RSI between pandas_ta and other methods at the end it comes out to a certain detail how exactly the values are calculated for example you might use sma or EMA in your formula leading to different results. The best way (a bit tedious unfortunately) check the formulas behind the functions and see which one fits your needs (there is no better or worse in this case it's simply knowing what exactly is happening under the hood).

    • @3rdpartylegends
      @3rdpartylegends 2 года назад +1

      @@CodeTradingCafe i matched the pandas_ta VWAP and the normal ta VWAP with a indicator in TradingView and pandas_ta is giving the exect result as TradingView indicator so i am going with pandas_ta VWAP.

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

      @@3rdpartylegends thank you for the heads up! You are lucky when I compare values they never match that quickly 😂

    • @3rdpartylegends
      @3rdpartylegends 2 года назад +1

      @@CodeTradingCafe there is an indiccator in TradingView name=SPARTAN SMC TOOL 1.0 could you look into it and if possible make a video on that. This indicator is about Smart money and it calculates higher highs and higher lows and many more pivot points like that.

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

      @@3rdpartylegends I have to check it but it's not always easy to reverse engineer unless the code is available somewhere

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

    Where is the csv from?

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

    If you reduce your margin to 1/1 the return is 209% (worse than buy and hold).

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

      Yes margin is advantageous when you have a good strategy.

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

      @@CodeTradingCafe my point is that 10,000% return with margin is not comparable to 200% without

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

      @@RubixMan99 I see, but generally it's easier to earn small bits frequently like fast predictions than buy and hold which is more like long term prediction.

  • @leobike-1920
    @leobike-1920 Год назад +1

    great job

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

      Thank you check the recent videos more interesting results there. Good luck

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

    Can you share me h1 timeframe Btcusd data?

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

    need more binance's transaction fee to be accurate

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

      Yes I usually add these at the end when I am satisfied with the strategy before considering a serious investment.

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

      @@CodeTradingCafe Can you add the exact cost of binance to this strategy?

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

      @@kodzuvu I am not sure, definitely can do probably manually modifying the class, but I will need the cost of binance is it percentage based?

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

    why would you publish this strategy to the public if you have that high return? Don't you think that if it is published it would not be doing that well anymore?

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

      Hi a lot of strategies can be profitable if used properly, I have couple of unpublished strategies for my trading so I don't mind spreading knowledge, it's mostly about sharing knowledge and learning from viewers comments, I learned to remain open to people's perspectives it's always interesting to know how every trader would surf the market.

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

    the max drawdown is -78% and you call it a good strategy bro !!! ??? hhh 😂🤔

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

      Hi, considering it's trading with 100% of the equity and using leverage at the same time, that's outstanding, any ' normal' strategy would have wiped the account.