Δ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 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!
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.
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!
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...)?
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.
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.
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?
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?
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.
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.
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?
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 .
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!
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.
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
@@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.
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
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?
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.
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
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.
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.
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.
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.
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.
Δ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.
Boss, you catched the gimmick. Pin 📌 for that my man
@@Algovibes yess...
Amazing video! Would love to see the vectorized version you mentioned in the video
Thx mate. Sure thing, thx for your feedback!
@@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!
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.
thanks mate!
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!
Extremely interesting suggestion. Thanks!
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...)?
Thanks my mate. Happy to read!
I have covered that in past videos (Optimizing parameters) - be kindly invited to check my other stuff.
Long time coming.. one of great videos and would move to see vectorized approach in another upcoming video of tours 👍
Thank you for your feedback. Will see what I can do!
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.
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.
Thanks a lot, another clearly explained strategy and coding. I would like to see the vectorised one too.
Thank you mate. Will see what I can do!
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?
Its "iterrows"
@@ericp.5533 yhea i found out. Took my way to long🤣
happens to the best :-)
I started watching your videos. Just brilliant. Thanks you .
Thanks mate. Happy to have you on board :-)
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?
hi mate, yes I did a couple of months ago. Cheers!
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
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.
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.
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?
Thanks mate. Appreciate you leaving a comment!
Great tutorial!
Do you do any one strategy including both short and long?
Thanks a lot mate. Yep I have covered shorting in previous videos as well!
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 .
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!
Great video as always my friend! Thanks a lot
Thanks for watching mate. Appreciate you leaving a comment :-)
I thought you had dropped your Dashboard tutorial.. is it available in the members area ?
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.
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
very interesting as usual !! thanks a lot
Awesome to get that from Voltaire personally 😁 Thx mate
sir now u not active on u tube , pls post video regularly ur video are very informative and practical
Hi mate, doing my best to post regularly but I cannot dedicate that much time into TH-cam currently. Thanks for your patience!
he's back!
He was never away :-) I just cannot dedicate that much time into TH-cam currently. Thanks for watching and your comment mate
@@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.
I could not find the python codes anywhere!
Be invited to become a channel member and get access to it!
Can you do some video showing maximum favourable and adverse excursion?
Interesting suggestion! Will see what I can do. Cheers mate
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
Ask chatgpt
Excellent
thx mate, happy to read!
amazing video, can you do one to build a volume breakout sort of strategy for equities please?
thanks buddy, will see what I can do. Appreciate the suggestion!
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?
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.
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
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.
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.
Thank you very much for the content, appreciate it!
Appreciate you watching my man!
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?
you could use yfinance instead for your data
I used a VPN. I think I used Germany as the source country.
Thanks for the video! Also, very much enjoying your Udemy course.
Hi mate, very happy to read. Thx!
Very nice!
Thank you mate!
Ottimo, bravissimo
Grazie Mille :-)
This is always going to male money in a bull market, though. The past history is perfect
Awesome
Thank you my man!
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.
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.
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.