I’ve been working on my own trading bot since last year. These videos are immensly helpful. Thanks for the amazing work. I’ve also been exploring your earlier vids, they are fantastic.
More to come! live testing and analysis on live trades, but it's kind of slow because I need to wait for the bot to gather enough data (2-3 weeks I guess).
FYI. when you request candles, the most recent candle will not be complete ("complete"=false), aka still forming. You need to filter this candle out to get the most accurate signals [x:-2].
Hi thank you, I thought the last uncomplete candle is Not considered because python discards the upper edge of the slice by default so if we use [:-1] the -1 candle (current candle) is discarded. But which line of code you were referring to exactly so I can check it out?
@@CodeTradingCafe You are right about [:-1] (forgot about inclusive/exclusive). I'm not familiar with oanda_candles since i use oandapyv20 directly for everything. It might be that that package sorts it out. This is a response i get when requesting 1 candle - {'instrument': 'EUR_USD', 'granularity': 'M1', 'candles': [{'complete': False, 'volume': 21, 'time': '2024-02-01T21:29:00.000000000Z', 'mid': {'o': '1.08704', 'h': '1.08706', 'l': '1.08704', 'c': '1.08704'}}]} everytime there is a tick the values change.
Great work. I taken your course on Udemy which is also excellent. I am planning to use this index option trading(India). I will test with small amounts with brokers in India and provide the feedback. Again Thanks a lot for sharing the Python code :)
Always interesting to see how you are doing things different to what I would do. In terms of coding standards, I would do an "early return" on the spread, i.e. if the spread is too large, then return out of the function, then you don't need to put it in your if/elif later on which would simplify your code. As you mentioned, the number of units would be calculated relative to the stop size such that you're consistently risking say 1% of your account per trade. I'm currently at a position where I can easily backtest and optimize a strategy. I now need to write some code to trade the same strategy in my broker account. Will be interesting to see how the live results compare to the backtest results and of course I'd like to try the strategies you've outlined.
Hi, thank you, I also enjoy your comments, somehow pushing for a better code (which I never focus on at first and then when the code is done and running I don't go back to improve it :) ). But regarding the strategies, lots of ideas around one strategy (this one in the video) there many ways to test it now, I am also thinking of higher timeframes but the trades number would be less so it's more waiting time. I will take it one step at a time, and see where it leads... and I will write better code but not for this Thursday because I already recorded the videos, sorry :)
Hi ! It's not really related to this video but I'm getting confused on how I should organize my codes around strategy building... Do you have a video about that ? Like, do you group your functions, if so how and where ? How do you sort your data, your results ? Thanks !
I absolutely support your question, simply because I am too messy with my codes and I am not doing great/elegant codes here on the channel. Ideally I wouldn't even use a notebook, just a python file, makes it easier to organize putting functions in different files depending on their usage and importing these files in the main code. That would be a good start. for the results the easiest is to put these in excel if you are trying different strategies for comparison.
Great content mate. Love to see more updated detailed guide on Bybit+Python API Setup , Backtesting Strategy, and Results Optimization. With another guide for demo trading account.
Amazing! Would u be kind enough to provide a csv or an excel file, with the exact entry points of the strategy, to be able to have as a reference? Having checked a single day, the entry points for long that lost would be date 2024-01-24 02:30:00 2024-01-24 14:00:00 2024-01-24 16:50:00 2024-01-24 17:05:00 and the entry points for long that won, should be date 2024-01-24 00:10:00 2024-01-24 03:05:00 2024-01-24 10:40:00 2024-01-24 13:35:00 2024-01-24 14:30:00 The above return in pips is ~6.5 pips Can you please confirm? Keep up the superbe work! Thanks
Hi, thank you for your support. Yes that would be possible, but I will have to reset the account because I used it to test different strategies, so the best is I reset the account run the strategy for 3 weeks and provide a clean csv, the format of the csv however id the one provided by Oanda there is all the information there but you will need to select whatever you need from it.
@@CodeTradingCafe another option would be to just run the code inside the notebook u had provided in the previous video when u introduced the strategy, and save the entry points in a csv. What do u think?
Yes I agree it works well, I am intending to run 2 versions of the code, one that we know and another one using trailing stop, put them in a race, and save trades for both, could score each trade if long or short, the SL and TP values, the price and date, and if the profit loss numbers for each trade.
Nice video. For me, the hardest part was watching the bot lose money and doing nothing because it is part of the statistics. However, I faced two issues and I am not sure if you encountered them or not: 1- There is a 5% difference between the backtest and the real trading (Not in the equity, it is in the trading decisions.), which makes a difference. 2- The bot was sensitive to the economic news in a negative way. However, it is making money in the end, but it needs more than a month to confirm that it is aligning with the backtest results.
Hi, there will be definitely a difference due to spread and fees, I honestly would't expect to get exactly the same results as the backtest, but if the backtest was good I expect the live trading to be good as well, less returns but still Ok. I hoe it will still go in the the positive direction.
Hi, I reviewed the code and there was a small delay in the live version (signal should be applied to open prices instead of closing prices) so it will execute trades like in the backtest, unless if there is another bug. I am trying it again for few weeks now...
Thank you for the update. One point to note is that during backtesting, discussions will not apply to the subsequent candle, which means it won't show that the position was closed. As a result, the backtest may indicate fewer consecutive failures than what might occur in reality. To clarify, I'm currently using another bot that has been yielding decent results. I've been testing it with a live account (real money), and it performed poorly when there were announcements from the USA regarding the economy. If you don't mind, I would like to use your bot in conjunction with the one I currently have. This approach could potentially increase the number of trades while maintaining an acceptable win rate.
Thank you for the heads up, I am currently fine tuning the bot during live trading it's a lot of trial and error I deploy it today on AWS because I was having some technical issues mainly connection and firewall... this also adds up to the challenge. Regarding using this bot, sure feel free, just be cautious it's not the best version yet. I am testing the same bot with trailing stop also I will make a video as soon as I get something.
Can we get trading journals from this library “Backtesting”…? If not then can you please create one video on how to create a complete Python function as same as Library “Backtesting” where we can all details how to analyse. Thanks in Advance…!
I tested the strategy on BTC/USD and ETH/USD pairs, they did decently on more recent data, whilst data from around 2020 caused long term draw downs on the 1 minute timeframe. Over all the strategy did really well
Thank you for the heads up. I think the best way to use this strategy is to optimize it (the parameters ruclips.net/video/IfoZaCGTJ_Q/видео.html ) every couple of weeks somehow keeping up with the current market. the 1 minute timeframe is too noisy for my liking, I will try 15min maybe for the next video.
It's hard to sort the strategies they are different running on different timeframes, some are for ranging markets others for trending markets, the best strategy is a combination of strategies like the ensembling idea in ML.
I saw a couple of videos were you used LSTM for predicting stock prices and if i remember correctly it was futile, have you tried using transformers? I'm trying that. If it doesn't look futile, I'll let you know.
Hi, no I haven't yet, it takes time and I was skeptical if it's worth it, but you are right what if transformers can predict the most probable sequence continuation... at the end this is how it works for LLMs. Good luck with this, if you have time and something interesting I would be curious to know.
@@CodeTradingCafe I'm skeptical too, but even of it doesn't work i hope to learn something out of it. Anyways it's a long journey to learn. If something looks promising I'll be sure to let you know. Also i think it would be good for you to have a discord or something for the community to also share their journey so that we can cover more ground as a collective.
Hi , thank you for your feedback, well the coding and learning will definitely be fun especially when the code runs at the end (you will probably forget about the trading money and stuff lol). Discord or telegram is too much for me to moderate, I am barely keeping up with youtube :)
Great video! thank you for great content, would it be possible to make one video of a trading bot that uses a simple stradegy but trades multiple symbols? 🙏
Great content, I just have one question: how do you connect to oanda using the API? I have a paper account and a live account but I don't know how to connect to it in my live account, I hope you know how to do it. Greetings from Mexico
Hi, you need to generate a token from Oanda web platform and you will need the account number. Check on Oanda's there is a selection "API" on the left menu, you can generate a token there, then use the token and account number in the code provided in my video.
Hi! Nice work and thank you for all. Im trying to implement the code to use on my platform xtb, can you help? Or maybe do a video on xtb? Thanks again.
Great content, I already enrolled you course and it's also great. One question, each trade with 3k units is the same as your are opening trades off 3k$?
Thanks for the fast replying, but in the best profit days is something like 0,3%, it's not a risk strategy apply 3.5K to get 10€? I mean, if it was 100% percent right I would apply more, but it's a little scary
You are right, I also missed the leverage, so the margin is almost 115 instead of 3500 USD, but yes it's aggressive lot sizing, however you are not risking the whole amount of the margin it's just the lot size until the stop loss that's the real risk value. So it's a high lot size but considering the SL distance we're just risking small part of the margin. I hope this makes sense.
They all have ups and downs depending on the market, usually you would have 2 or 3 running in parallel and covering up for each others to be always in the positive. Some I can't publish because they were done for clients. The best is to have a hybrid approach, so the algorithm send you an alert for an opportunity and you decide if you need to open the trade or not, this was my best experience and by far the most profitable.
Thanks for the video, but my question is what if you use 9 and 21 emas for trend detection wouldnt make the bot capture more market trades. whats your say on that?
@@CodeTradingCafeOkay, thanks for the answer. I saw there is MetaTrader5 Libary for Python so it seems there is a possiblity to hook python scripts to MT5 terminal which would make it universal to all brokers as nearly all of them offer metatrader access to the markets. Maybe that would be a nice idea for a future video. Thanks for you content.
Hey, nice material right here! Thank you for the information! One question: how do you take the candle.ask.o value? I don't see any ASK field in DataFrame
@@CodeTradingCafe Yep, in the trading part. I was curious where I can find that information about ask field, it seems like XTB doesn't bring that field.
Do your results factor in commission and slippage? When I was trading futures 2007 to 2014 using Tradestation language, (which is very powerful and simple), I was only able to get decent returns using a 15minute chart or higher. Thanks for your videos.
I agree higher timeframes are easier for systematic trading, less noise. I don't add commissions and trading fees unless the strategy is doing really well, I start testing raw indicators (no trading fees or slippage). There is an easy way to add these in backtesting just pass the parameter commission=0.0002 (spread for forex) and increase the number depending on the broker's fees approximations.
Hi, this doesn't run in Metatrader you need to run it only in Python, so a minimum coding level might be required. But if you don't know coding you can still trade the strategy manually it's a great simple and very easy. The backtest shows good results as well check it here ruclips.net/video/IfoZaCGTJ_Q/видео.html
Could you clear up a doubt for me? I created a demo account to do more testing, but it turns out that the token is invalid and there are errors in the code lines. Is there any solution? Or does it only work on the normal account??
hi, i have a question if you help. İ wrote a code and it runs for a coin. but i can not run two or more different coins at the sime. How can we run two or more codes at the same time in python
@@CodeTradingCafe i am not sure that i could ask properly. İ mean in python i can work only one code at the same time. i want to run for examle 5 the same codes for different coins etc and i can not do it. My question is related to python not to a code. İ thought you may know the answer
Will it take our money and invest it automatically? And pls make a ultimate python trading bot with AI ML and aal the strategies possible with AI prediction the stock price etc
It's a good example if you are trying to learn python for algorithmic trading, I wouldn't advise using a program if you're not familiar with the code. That being said you can always use the strategy manually it's proven that it works.
Thank you for sharing this code It would be great if you implement the CCXT library to it. Then we can connect it to different crypto exchanges sorry to ask, but I am not technical
Hi, yes it's a paper account, for testing but I noticed fees are included and the spread of course, ... and we are sure there is no look ahead bias in this case.
Hi , i have a set amount of trading rules , i want to find out how can i automate this ? Is there someone i can hire to code it for me and if so where can i find them ?
I would have said I can do it, but currently I am overbooked, if the rules are relatively simple send me an email with a description, but if you assume it's complex or might be time consuming at the moment can't do much.
@@CodeTradingCafe hmm never taken in to account the sessions yet... But it's totally achievable as on copy trading I see there are multiple bot driven account with good returns and safe /stable.. There are some with perfect Winrate but they eventually washout.
@@CodeTradingCafe it was good time to invest last year mid... Not now... I missed by the way... Or I could have made 2x in 6 month easily... On eth and btc alone..
Im curious, can we make the script to be able to run on 2 pairs or more instead of just one pair. I mean ofc i can just run another script again but is it possible to run it on the same script?
Yes the idea to do it this way, run it on uncorrelated assets, but you also need new set of parameters so going back to my previous video on optimization.
I recommend "Leveraged Trading" (beginners) and "Systematic Trading" (more sophisticated framework) by Robert Carver. I recommend them in general, but he has a framework to use different rule sets on different instruments in a single system. It considers the overall capital, allocates towards the subsystems depending on current risk estimations and more. And it is relatively simple.
I killed it because I wanted to focus on other strategies, but usually lower timeframes are eaten by fees, although some weeks were amazingly profitable 5days/5 some other weeks were a misery, it can be improved though.
Hi, I have no experience in the Indian market, try to adapt any of my codes if you have been trading Indian assets you will probably do better than me.
@@CodeTradingCafe I'm doing the same thing with the same code, but I have no profit. and the tests are all negative. i don't understand what i'm doing wrong....
@@CodeTradingCafe definitely wishing you good luck! would be great if you could perform a slippage analysis after you have gathered some data (suggesting at least 6m) - i.e. take real results and backtest results for same period and calculate the difference in result :)
this is totally bogus, because the results will favour the 1 minute timeframe and you could get like 100 trades per day of 0.01% profit per trade, which is totally unreal, I use 0.3% comission when I test my strategies and I have many profitable ones (the downside is that some of the strategies take like 1 trade in 100-200 days, but the average is below 20-30 days).
I agree, actually it's harder to build a scalping fully automated strategy, but if you use daily timeframe it's really much easier and it covers fees also comfortably, however like you said the bot would have around 10 trades per year (in my case) with a high winrate, in this case you can run it on multiple assets simultaneously to increase the number of trades.
@@CodeTradingCafe YES, all of the channels with bots and strategies and backtesters don`t input the real fees that a trade can inccur, if a strategy has less than 1% profit per trade, disregard it. I have strategies with 10 trades in 4 years and they beat buy & hold easily, but diversifying it over multiple asset class is the best way to go.
The more I look at automated strategies the more I realize, manual trading is the way to go. Auto trading rely almost purely on indicators which are many decades old. Putting all your faith in indicators is not a recipe for success.
Hi, I agree, manual is more efficient. Fully automated trading is good on daily timeframe so slow strategies fit well. The best is hybrid trading, parallel bots with different strategies will only send you alerts of patterns on different markets... they do the scanning part, you as a trader take decisions, this is really an efficient approach.
@CodeTradingCafe add a smart dca logic to it and it will be even better without loses,split the dca in a smart way for the worst case scenario and you will never lose
I’ve been working on my own trading bot since last year. These videos are immensly helpful. Thanks for the amazing work. I’ve also been exploring your earlier vids, they are fantastic.
Glad you like them! Thank you for your support!
Thank you for creating these videos, they're exactly what I have been looking for!
Thank you for your support! Glad you like these vids.
Wow as requested by many u listened keep it up!
More to come! live testing and analysis on live trades, but it's kind of slow because I need to wait for the bot to gather enough data (2-3 weeks I guess).
@@CodeTradingCafe which broker used here
Thanks!
Thank you for your support!
Thanks for your dedication on sharing your knowledge, learning and findings, you've earned a new supporter 🙂
Awesome, thank you! and welcome aboard.
Exciting! Hopefully it works out! Looking forward to the final analysis!
Thank you for your support. More to come, but it's a bit slow since I need to wait for the bot to gather some real time data.
FYI. when you request candles, the most recent candle will not be complete ("complete"=false), aka still forming. You need to filter this candle out to get the most accurate signals [x:-2].
Hi thank you, I thought the last uncomplete candle is Not considered because python discards the upper edge of the slice by default so if we use [:-1] the -1 candle (current candle) is discarded. But which line of code you were referring to exactly so I can check it out?
@@CodeTradingCafe You are right about [:-1] (forgot about inclusive/exclusive). I'm not familiar with oanda_candles since i use oandapyv20 directly for everything. It might be that that package sorts it out. This is a response i get when requesting 1 candle - {'instrument': 'EUR_USD',
'granularity': 'M1',
'candles': [{'complete': False,
'volume': 21,
'time': '2024-02-01T21:29:00.000000000Z',
'mid': {'o': '1.08704', 'h': '1.08706', 'l': '1.08704', 'c': '1.08704'}}]} everytime there is a tick the values change.
It's an edge case but It can be annoying when you get a signal in one moment and then not in the next because the price has moved slightly.
Well honestly I am never sure of edge cases until I try many times and observe what's happening, funny it's one tedious task :)
Great work. I taken your course on Udemy which is also excellent. I am planning to use this index option trading(India). I will test with small amounts with brokers in India and provide the feedback. Again Thanks a lot for sharing the Python code :)
Best of luck! Thank you for your support!
How does this go?
Always interesting to see how you are doing things different to what I would do. In terms of coding standards, I would do an "early return" on the spread, i.e. if the spread is too large, then return out of the function, then you don't need to put it in your if/elif later on which would simplify your code.
As you mentioned, the number of units would be calculated relative to the stop size such that you're consistently risking say 1% of your account per trade.
I'm currently at a position where I can easily backtest and optimize a strategy. I now need to write some code to trade the same strategy in my broker account. Will be interesting to see how the live results compare to the backtest results and of course I'd like to try the strategies you've outlined.
Hi, thank you, I also enjoy your comments, somehow pushing for a better code (which I never focus on at first and then when the code is done and running I don't go back to improve it :) ). But regarding the strategies, lots of ideas around one strategy (this one in the video) there many ways to test it now, I am also thinking of higher timeframes but the trades number would be less so it's more waiting time. I will take it one step at a time, and see where it leads... and I will write better code but not for this Thursday because I already recorded the videos, sorry :)
Hi !
It's not really related to this video but I'm getting confused on how I should organize my codes around strategy building...
Do you have a video about that ?
Like, do you group your functions, if so how and where ?
How do you sort your data, your results ?
Thanks !
I absolutely support your question, simply because I am too messy with my codes and I am not doing great/elegant codes here on the channel. Ideally I wouldn't even use a notebook, just a python file, makes it easier to organize putting functions in different files depending on their usage and importing these files in the main code. That would be a good start. for the results the easiest is to put these in excel if you are trying different strategies for comparison.
Very exciting! How about adding a sentiment analysis to the strategy? Perhaps based on machine learning? :)
Great suggestion! I thought about it and I am still postponing this since a year lol... but I will get there one day.
Great content mate. Love to see more updated detailed guide on Bybit+Python API Setup , Backtesting Strategy, and Results Optimization. With another guide for demo trading account.
Hi, thank you for your support, optimization was done in different videos, I will try to show something live soon.
@@CodeTradingCafe Thanks for replying! You just earned a sub. Also, do you've a discord group where we could share ideas and discuss more about it?
Hi, thank you, glad you like the content. I don't have a discord unfortunately, it's hard to monitor and moderate. Time is squeezed usually :)
Amazing! Would u be kind enough to provide a csv or an excel file, with the exact entry points of the strategy, to be able to have as a reference?
Having checked a single day, the entry points for long that lost would be
date
2024-01-24 02:30:00
2024-01-24 14:00:00
2024-01-24 16:50:00
2024-01-24 17:05:00
and the entry points for long that won, should be
date
2024-01-24 00:10:00
2024-01-24 03:05:00
2024-01-24 10:40:00
2024-01-24 13:35:00
2024-01-24 14:30:00
The above return in pips is ~6.5 pips
Can you please confirm?
Keep up the superbe work!
Thanks
Hi, thank you for your support. Yes that would be possible, but I will have to reset the account because I used it to test different strategies, so the best is I reset the account run the strategy for 3 weeks and provide a clean csv, the format of the csv however id the one provided by Oanda there is all the information there but you will need to select whatever you need from it.
@@CodeTradingCafe another option would be to just run the code inside the notebook u had provided in the previous video when u introduced the strategy, and save the entry points in a csv. What do u think?
Yes I agree it works well, I am intending to run 2 versions of the code, one that we know and another one using trailing stop, put them in a race, and save trades for both, could score each trade if long or short, the SL and TP values, the price and date, and if the profit loss numbers for each trade.
Great !
Concise and helpful! Thanks alot!
Is it possible to test with MT5 demo account and adapt the code with only MT5 Python API functions?
Thank you, I think I will prioritize MT5 python interface now, I am getting a lot of requests on this topic.
Nice video. For me, the hardest part was watching the bot lose money and doing nothing because it is part of the statistics. However, I faced two issues and I am not sure if you encountered them or not:
1- There is a 5% difference between the backtest and the real trading (Not in the equity, it is in the trading decisions.), which makes a difference.
2- The bot was sensitive to the economic news in a negative way.
However, it is making money in the end, but it needs more than a month to confirm that it is aligning with the backtest results.
Hi, there will be definitely a difference due to spread and fees, I honestly would't expect to get exactly the same results as the backtest, but if the backtest was good I expect the live trading to be good as well, less returns but still Ok. I hoe it will still go in the the positive direction.
@@CodeTradingCafe i was referring to something else on my comment.
Hi, I reviewed the code and there was a small delay in the live version (signal should be applied to open prices instead of closing prices) so it will execute trades like in the backtest, unless if there is another bug. I am trying it again for few weeks now...
Thank you for the update. One point to note is that during backtesting, discussions will not apply to the subsequent candle, which means it won't show that the position was closed. As a result, the backtest may indicate fewer consecutive failures than what might occur in reality. To clarify, I'm currently using another bot that has been yielding decent results. I've been testing it with a live account (real money), and it performed poorly when there were announcements from the USA regarding the economy.
If you don't mind, I would like to use your bot in conjunction with the one I currently have. This approach could potentially increase the number of trades while maintaining an acceptable win rate.
Thank you for the heads up, I am currently fine tuning the bot during live trading it's a lot of trial and error I deploy it today on AWS because I was having some technical issues mainly connection and firewall... this also adds up to the challenge. Regarding using this bot, sure feel free, just be cautious it's not the best version yet. I am testing the same bot with trailing stop also I will make a video as soon as I get something.
Can we get trading journals from this library “Backtesting”…?
If not then can you please create one video on how to create a complete Python function as same as Library “Backtesting” where we can all details how to analyse.
Thanks in Advance…!
Actually yes you can, you have access to all the trades in the results. You can extract these there is a variable named _trades if I recap correctly.
I tested the strategy on BTC/USD and ETH/USD pairs, they did decently on more recent data, whilst data from around 2020 caused long term draw downs on the 1 minute timeframe. Over all the strategy did really well
.. Which TF worked for eth and BTC...
Thank you for the heads up. I think the best way to use this strategy is to optimize it (the parameters ruclips.net/video/IfoZaCGTJ_Q/видео.html ) every couple of weeks somehow keeping up with the current market. the 1 minute timeframe is too noisy for my liking, I will try 15min maybe for the next video.
I tried it on a 15 mns window, 😢
@@CodeTradingCafe But if we keeps on optimizing the strategy in couple of weeks , arent we running a curve fitted system then ?
We'd love a video stating the top 5 strategies of the channel
It's hard to sort the strategies they are different running on different timeframes, some are for ranging markets others for trending markets, the best strategy is a combination of strategies like the ensembling idea in ML.
I saw a couple of videos were you used LSTM for predicting stock prices and if i remember correctly it was futile, have you tried using transformers? I'm trying that. If it doesn't look futile, I'll let you know.
Hi, no I haven't yet, it takes time and I was skeptical if it's worth it, but you are right what if transformers can predict the most probable sequence continuation... at the end this is how it works for LLMs. Good luck with this, if you have time and something interesting I would be curious to know.
@@CodeTradingCafe I'm skeptical too, but even of it doesn't work i hope to learn something out of it. Anyways it's a long journey to learn. If something looks promising I'll be sure to let you know. Also i think it would be good for you to have a discord or something for the community to also share their journey so that we can cover more ground as a collective.
Hi , thank you for your feedback, well the coding and learning will definitely be fun especially when the code runs at the end (you will probably forget about the trading money and stuff lol). Discord or telegram is too much for me to moderate, I am barely keeping up with youtube :)
Please let me know how to Apply these Strategies in the Indian Derivatives Market ?😊
I am not familiar with Indian market, but I Assume with a little bit of tuning a good strategy should perform well on any chart.
@@CodeTradingCafe Can you help me with Nifty Banknifty indices Strategy ?
Great video! thank you for great content, would it be possible to make one video of a trading bot that uses a simple stradegy but trades multiple symbols? 🙏
Hi thank you, yes. actually this bot can be used for other currencies as well but you need to change the parameters a bit.
@@CodeTradingCafe what parameters should I adjust to make the strategy suitable for different symbols? TP and SL ?
This is soo cool...now, is that visual studio code you are using? And is there anything else needed for trades to happen on live data.?
Hi, thank you, yes it's VSCode and you just python and some packages that you can easily pip install
@@CodeTradingCafe alright thank you very much..
Awesome tutorial man, been looking into this for a while. Assuming I can use any platform that allows API generation?
Yes, absolutely you have brokers that allow python trading through their APIs (IB, Binance, Oanda...)
This is really great! Thank you for sharing! 🙏
Glad you enjoyed it!
You are doing a great job
Keep it up 🎉👏
Thank you so much for your support.
looking forward the follow up video :) maybe 2 weekly update please?
:) I am waiting to gather more data, since drawdown periods can last 3 weeks according to the backtest.
Great content, I just have one question: how do you connect to oanda using the API? I have a paper account and a live account but I don't know how to connect to it in my live account, I hope you know how to do it. Greetings from Mexico
Hi, you need to generate a token from Oanda web platform and you will need the account number. Check on Oanda's there is a selection "API" on the left menu, you can generate a token there, then use the token and account number in the code provided in my video.
is there any way to use this in trading view ?
it must be translated to pinescript language
Hi! Nice work and thank you for all. Im trying to implement the code to use on my platform xtb, can you help? Or maybe do a video on xtb? Thanks again.
Hi, I have never used xtb, you might need to go through their documentation following the same structure from the codes in this channel.
Good job!
Does it work with Crypto exchanges like Bybit , Binance ... ?
The way it is now it works on Oanda, for other platforms we need to use different API.
Thanks for respond
Are you have to change the whole script for that?
@@CodeTradingCafe
Not all but the part where it connects to the market so, let's say half of the code.
Great content, I already enrolled you course and it's also great. One question, each trade with 3k units is the same as your are opening trades off 3k$?
Hi, almost yes if EUR is 1.15 USD for example it would be 3450 USD
Thanks for the fast replying, but in the best profit days is something like 0,3%, it's not a risk strategy apply 3.5K to get 10€? I mean, if it was 100% percent right I would apply more, but it's a little scary
You are right, I also missed the leverage, so the margin is almost 115 instead of 3500 USD, but yes it's aggressive lot sizing, however you are not risking the whole amount of the margin it's just the lot size until the stop loss that's the real risk value. So it's a high lot size but considering the SL distance we're just risking small part of the margin. I hope this makes sense.
hi, very nice code. on which platfrom are you running the code over the time?
AWS cloud, using EC2, elastic compute.
So among the algorithms you wrote, which one is the strongest?
They all have ups and downs depending on the market, usually you would have 2 or 3 running in parallel and covering up for each others to be always in the positive. Some I can't publish because they were done for clients. The best is to have a hybrid approach, so the algorithm send you an alert for an opportunity and you decide if you need to open the trade or not, this was my best experience and by far the most profitable.
@@CodeTradingCafe thank you
Thanks for the video, but my question is what if you use 9 and 21 emas for trend detection wouldnt make the bot capture more market trades.
whats your say on that?
There is only one way to find out, backtesting and forward testing.
Could you show how to implement this on a trader that does not require fully verified accounts to access the API on a paper account?
As far as I know, not aware of any platforms offering APIs without verifying and getting your details.
@@CodeTradingCafeOkay, thanks for the answer. I saw there is MetaTrader5 Libary for Python so it seems there is a possiblity to hook python scripts to MT5 terminal which would make it universal to all brokers as nearly all of them offer metatrader access to the markets. Maybe that would be a nice idea for a future video. Thanks for you content.
Hi, very nice code. On which plattfrom are you running the code ?
AWS cloud, using EC2, elastic compute.
Hey, nice material right here! Thank you for the information! One question: how do you take the candle.ask.o value? I don't see any ASK field in DataFrame
I think I am not using it it's just a test to see if I can get the data.
@@CodeTradingCafe you are using it for the spread.
@@CodeTradingCafe You are using it for spread.
Yes below in the trading part, I thought you meant the previous part where I test the candles download.
@@CodeTradingCafe Yep, in the trading part. I was curious where I can find that information about ask field, it seems like XTB doesn't bring that field.
Do your results factor in commission and slippage? When I was trading futures 2007 to 2014 using Tradestation language, (which is very powerful and simple), I was only able to get decent returns using a 15minute chart or higher. Thanks for your videos.
I agree higher timeframes are easier for systematic trading, less noise. I don't add commissions and trading fees unless the strategy is doing really well, I start testing raw indicators (no trading fees or slippage). There is an easy way to add these in backtesting just pass the parameter commission=0.0002 (spread for forex) and increase the number depending on the broker's fees approximations.
Hello, how can I run your robot in Metatrader?.
Is there a specific platform?
Hi, this doesn't run in Metatrader you need to run it only in Python, so a minimum coding level might be required. But if you don't know coding you can still trade the strategy manually it's a great simple and very easy. The backtest shows good results as well check it here ruclips.net/video/IfoZaCGTJ_Q/видео.html
Just bought your courses. Love your work. You keep giving and sharing! Hope you will do very well.
Much appreciated! thanks a lot for your kind support, and good luck to you!
Could you clear up a doubt for me? I created a demo account to do more testing, but it turns out that the token is invalid and there are errors in the code lines. Is there any solution? Or does it only work on the normal account??
Hi, it should also work on demo accounts.
@@CodeTradingCafe thkx I will try again
hi, i have a question if you help. İ wrote a code and it runs for a coin. but i can not run two or more different coins at the sime. How can we run two or more codes at the same time in python
The way this code in the video is built you will need to run different codes for different assets, it's not adapted for multi currencies.
@@CodeTradingCafe i am not sure that i could ask properly. İ mean in python i can work only one code at the same time. i want to run for examle 5 the same codes for different coins etc and i can not do it. My question is related to python not to a code. İ thought you may know the answer
@@er-gec2546use loops for each coin...
Looking good :) what about your transactional fees at your broker. I don't see where you take this into account.
Hi, they are directly withdrawn from my account I can see them in the history. so far it's all positive let's wait few more weeks and see...
Will it take our money and invest it automatically? And pls make a ultimate python trading bot with AI ML and aal the strategies possible with AI prediction the stock price etc
It's a good example if you are trying to learn python for algorithmic trading, I wouldn't advise using a program if you're not familiar with the code. That being said you can always use the strategy manually it's proven that it works.
Thank you for sharing this code
It would be great if you implement the CCXT library to it. Then we can connect it to different crypto exchanges
sorry to ask, but I am not technical
Thanks for the idea! it's on my list but time is always tight...
your explanation is easy to understand thx for the video
Glad to hear that! Thank you for your support.
I do know Python nothing. How do I do Live Trading Bot Strategy In Python. I would appreciate your advise.
Hi, you can still trade this strategy manually we did a backtest in the previous video ruclips.net/video/C3bh6Y4LpGs/видео.html
Is this paper trading of real trading which involves money?
Considering he is live testing this bot, I would assume its paper trading
Edit: fixed spelling
Hi, yes it's a paper account, for testing but I noticed fees are included and the spread of course, ... and we are sure there is no look ahead bias in this case.
@@CodeTradingCafe cool thanks
Hi , i have a set amount of trading rules , i want to find out how can i automate this ? Is there someone i can hire to code it for me and if so where can i find them ?
I would have said I can do it, but currently I am overbooked, if the rules are relatively simple send me an email with a description, but if you assume it's complex or might be time consuming at the moment can't do much.
Bro share strategy backtesting ideas for crypto... It's 24hr market.. Mostly ETH and BTC Can be good...
I never traded crypto, I was just investing (which was a bad idea). Does is move as quickly during sessions off too?
@@CodeTradingCafe hmm never taken in to account the sessions yet... But it's totally achievable as on copy trading I see there are multiple bot driven account with good returns and safe /stable.. There are some with perfect Winrate but they eventually washout.
@@CodeTradingCafe it was good time to invest last year mid... Not now... I missed by the way... Or I could have made 2x in 6 month easily... On eth and btc alone..
I invested in the good times 2 years ago, but got greedy and kept the money in while the crypto crash was obvious.
@@CodeTradingCafe that's why I like futures... No need to wait years.. For nominal profits... 😅
I have downloaded the file...can it be transferred to tradingview.how do I change this file to an indicator in tradingview
Hi, unfortunately no, this is python and tradingview use pine I guess.
Im curious, can we make the script to be able to run on 2 pairs or more instead of just one pair. I mean ofc i can just run another script again but is it possible to run it on the same script?
Yes the idea to do it this way, run it on uncorrelated assets, but you also need new set of parameters so going back to my previous video on optimization.
I recommend "Leveraged Trading" (beginners) and "Systematic Trading" (more sophisticated framework) by Robert Carver. I recommend them in general, but he has a framework to use different rule sets on different instruments in a single system. It considers the overall capital, allocates towards the subsystems depending on current risk estimations and more. And it is relatively simple.
can’t wait to see the update. you should do weekly updates of this trading bot
It's slow, and sometimes technical issues :) but it's nice
@@CodeTradingCafe would love to know the issues and solutions.
Any updates on how this performed over a longer term?
I killed it because I wanted to focus on other strategies, but usually lower timeframes are eaten by fees, although some weeks were amazingly profitable 5days/5 some other weeks were a misery, it can be improved though.
@@CodeTradingCafe Ah ok. It'd be awesome to see a recap of the performance with some analysis!
At some point I did a quick recap ruclips.net/video/buLNFOvHK8o/видео.html
please make a video live on Indian market like Nifty or Banknifty ,may be on paper trade and see the result.
Hi, I have no experience in the Indian market, try to adapt any of my codes if you have been trading Indian assets you will probably do better than me.
Bro, the code is there, give it a go and share the results
Can I use api of ICMarkets?
Yes you can, check their documentation and few examples you can translate this code to ICM
awesome, thanks for getting to this one..more please :)
More to come! Thank you for your support.
awsome, thanks for sharing this !!
Glad you liked it!
Thank you bro! For what you do!
Thank you for your support! Glad you liked this one.
Amazing !
Thank you!
why this strategy ? it is one of the most random and unprofitable. did you take it for live trading ?
Hi, I find it simple and profitable, why not leveraging noise with BB and trend with EMAs.
@@CodeTradingCafe I'm doing the same thing with the same code, but I have no profit. and the tests are all negative. i don't understand what i'm doing wrong....
That's weird, actually wait for the next 2 vids I am recording now, I updated some details I will republish the updated version. Hang in there :)
Sir if I run it live trading bot in While Loop,,, what problem will faces? and which is better scheduler or whileloop.... thank U..I m from india
Hi, it wouldn't work unless you add a sleep function of 5 minutes, scheduler works better in this case. Good luck !
Bro please do video on vector BT..
Man I know, I am really sorry, I am not efficient these days.
@@CodeTradingCafe may GOD bless you
You should give the links of the best worked strategies so that you may gain more views and audience may get more better strategies
Hi, thank you, maybe I already slipped some hints ... in previous videos ;)
Thank you a lot for your works
Thank you for your support! Glad you like these videos.
Thank you so much
Thank you for your support.
wow cool man!
Thank you for your support! wish this bot a good luck :)
@@CodeTradingCafe definitely wishing you good luck! would be great if you could perform a slippage analysis after you have gathered some data (suggesting at least 6m) - i.e. take real results and backtest results for same period and calculate the difference in result :)
This is one great idea! comparing the bot to backtesting on the same period! Thanks!
Thats good for real
Well it's just few days now, hopefully next week will be good as well.
Good job
Thanks, thank you for your comment.
I actually test this strategy i add lots/volume calculation with risk management 1% on EURUSD and XAUUSD
Somebody that did this for MetaTrader 5?
not me :) sorry only python
this is totally bogus, because the results will favour the 1 minute timeframe and you could get like 100 trades per day of 0.01% profit per trade, which is totally unreal, I use 0.3% comission when I test my strategies and I have many profitable ones (the downside is that some of the strategies take like 1 trade in 100-200 days, but the average is below 20-30 days).
I agree, actually it's harder to build a scalping fully automated strategy, but if you use daily timeframe it's really much easier and it covers fees also comfortably, however like you said the bot would have around 10 trades per year (in my case) with a high winrate, in this case you can run it on multiple assets simultaneously to increase the number of trades.
@@CodeTradingCafe YES, all of the channels with bots and strategies and backtesters don`t input the real fees that a trade can inccur, if a strategy has less than 1% profit per trade, disregard it. I have strategies with 10 trades in 4 years and they beat buy & hold easily, but diversifying it over multiple asset class is the best way to go.
interesting
Thank you, glad you liked it!
The more I look at automated strategies the more I realize, manual trading is the way to go. Auto trading rely almost purely on indicators which are many decades old. Putting all your faith in indicators is not a recipe for success.
Hi, I agree, manual is more efficient. Fully automated trading is good on daily timeframe so slow strategies fit well. The best is hybrid trading, parallel bots with different strategies will only send you alerts of patterns on different markets... they do the scanning part, you as a trader take decisions, this is really an efficient approach.
@@CodeTradingCafe I mainly use daily timeframe also. I try not go against positive swap direction. It get's a little boring 😄
It's a good approach, you can deploy an algorithm to scan the market for more than one asset, you will get more signals,... less boring :)
@CodeTradingCafe add a smart dca logic to it and it will be even better without loses,split the dca in a smart way for the worst case scenario and you will never lose
Thinking about it ... figuring out what would be the best/safest way.
Thanks a lot for your comments, I will try this out see if it's worth more research time.
@@CodeTradingCafe it is,my bot is making gains like this,when you try im waiting to see your results
It would be great if you provide your email or linkedIn. I am a data scientist and I want to ask 1-2 questions from you.
Hi, thank you for your support, my email is in the about section of this channel codingntrading gmail com