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!
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
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.
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...
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).
@@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
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!
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"?
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 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 :)
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.
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 :)
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 ?
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.
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" ?
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.
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😁
@@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!!
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.
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!
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.
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!
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
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).
@@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 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.
@@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.
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?
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.
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.
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!
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
Hello CodeTrading!
Thanks for showing Pandas TA and integrating it with the Backtesting package!
KJ
😎
I like both tools, very straightforward and easy to apply and makes my code more elegant. Thank you for your comment!
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.
Thank you for your kind support, check this playlist, let me know if it's interesting.
@@CodeTradingCafe can you show the code through which you can download a csv file on eth history on 15m timeframe?
@@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!
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...
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.
Interesting. I'm more into stocks rather the cryptos. It would be interesting testing the strategy with a bunch of stocks. Thanks man!
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
@@CodeTradingCafe Great! I'll be looking forward to watching those videos!
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
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).
@@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
Please combine with volume profile & VWAP
It's a good idea to include volume, thank you.
Hi, very intresting video :). Please where did you get the spreadsheet? Tnx
You can get data from yfinance or dukascopy. Good luck!
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!
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"?
thanks again. Do you have any videos that show how to automate the trading strategy please? ideally using bybit apis?
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.
@@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
@@preetipics Only Oanda so far just as an example because I had the code I have been using.
@@CodeTradingCafe ok cool, thanks
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?
Hi, no nothing special for the EMA. Did you use the 15 min timeframe?
@@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 :)
I know it's frustrating, probably a small detail somewhere... hard to find sometimes
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.
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 :)
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 ?
Thank you for your comment, I haven't tried fast trading, but if you have a specific idea let me know this sounds interesting.
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.
Yes surprisingly good, I think there is a potential here I will definitely revisit in a future video
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" ?
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.
Very well made content and strategy. Would be even more useful if we can optimise the parameters for the given timeframes
Thank you for your support, I recently uploaded a video on optimization I think we can use it for any strategy.
great video, where you get the data file from?
Yfinance or dukascopy mainly. Thanks for the comment.
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😁
Keep us posted, thank you 🙂
Hello man! Thank you very much, do you know where I can get the same time frame data for ethereum, solana, cardano ... would appreciate
Hi, dukascopy is a good source they have a nice interface.
@@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!!
@@CodeTradingCafe found how to extract! thanks man! meanwhile would appreciate the other question I have made regarding the myclosedistance variable
The distances difficult to say you have to try it and correct along.
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.
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!
@@CodeTradingCafe Looking forward to your video. Thank you in advance.
@@CodeTradingCafe this would be massively helpful if you could pls :)
thankyou so much for creating such a valuable content. really appreciate your time and effort to educate
Thank you again for your support, much appreciated.
The real money maker would be to combine this strategy with another which is profitable in a bear market
It's surprisingly profitable for a simple approach I will definitely revisit and improve upon.
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.
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!
hi, where I can get the input data on an ongoing basis (for ej. every 5 minutes of XBTUSD) thanks in advance :)
Hi, the easiest is yfinance, but for live trading also your broker might have an API. Check my last video for broker API example.
... yfinance can also give you live price
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
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).
@@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.
@@3rdpartylegends thank you for the heads up! You are lucky when I compare values they never match that quickly 😂
@@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.
@@3rdpartylegends I have to check it but it's not always easy to reverse engineer unless the code is available somewhere
Where is the csv from?
Dukascopy
If you reduce your margin to 1/1 the return is 209% (worse than buy and hold).
Yes margin is advantageous when you have a good strategy.
@@CodeTradingCafe my point is that 10,000% return with margin is not comparable to 200% without
@@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.
great job
Thank you check the recent videos more interesting results there. Good luck
Can you share me h1 timeframe Btcusd data?
done, it's in the description, good luck!
need more binance's transaction fee to be accurate
Yes I usually add these at the end when I am satisfied with the strategy before considering a serious investment.
@@CodeTradingCafe Can you add the exact cost of binance to this strategy?
@@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?
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?
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.
the max drawdown is -78% and you call it a good strategy bro !!! ??? hhh 😂🤔
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.