Dude the issue is you're essentially building a hfts and back testing it without accounting for platform fees or spreads
@maxnator4 күн бұрын
You can just multiply the profits by a factor based on lotsize to account for commissions and spreads.
@CodeTradingCafe3 күн бұрын
Hi, commissions are taken into account in the backtest, check the backtester function there is a parameter "commission" you can increase and change the values for experimentation. ... also the daily timeframe is not usually affected by fees, because the range of the price is wide enough to easily cover up for trading costs, on lower timeframes however this becomes problematic.
@Audem_arsКүн бұрын
@@CodeTradingCafe yea true but you got spread as well to factor in which changes throughout the day. In the daily timeframe I can see it working. I tried out the formula and threw it into high frequency bot so gains were small obviously. What's your tp/sl set at?
@Audem_arsКүн бұрын
@@maxnator but your spread cost definitely increases as you increase lotsize and commission may depending on your plan with the broker. So yea I what you're saying. Are you running this code?
@monela26965 сағат бұрын
Did you seriously call Daily chart hft?
@beliebigerusername5 күн бұрын
i really like your videos - so high in quality and clean in insight and code!
@CodeTradingCafe3 күн бұрын
Happy to hear that! I appreciate your support.
@TheEcherriman5 күн бұрын
Once again, thank you for your expertise and generosity
@CodeTradingCafe5 күн бұрын
So nice of you, thank you for your support!
@billmietelski6 күн бұрын
The intro mentions 14 stocks, 7 years of data, and a random entry. Stocks have postivite drift. Do your tests include a comparison to simply buying & holding these same stocks? (I bookmarked the video to finsh watching later :)
@Peter-wg7br5 күн бұрын
Yes, the random entries would indeed produce a random result. I think it's the trailing stop in a long term trending market that results in an average positive result. If this is true, the buy trades should outperform the sell trades.
@gvidalcantavella5 күн бұрын
But keep in mind that short trades are less common but usually more profitable, since they have shorter term duration but the price moves quicker that in longer term. In some stocks such for instance Tesla this strategy may work pretty nice. I'll give it a try with highly volatile stocks.
@Ricky_Micky_Dicky5 күн бұрын
If you type in the tickers you'll see lot of them are not stocks, example QQQ is nasdaq index, JNK is junk bond etf etc.... Still a lot of American stocks in there which we know outperformed the world with hindsight bias.
@lorensaunders60345 күн бұрын
@@gvidalcantavella shorts are generally more profitable in a shorter time frame on a per trade basis but over the long term not so much.
@billmietelski5 күн бұрын
@@Ricky_Micky_Dicky Yeah, instead of stocks I should have said 'equities'. Thats what happens when I reply before my morning coffee, lol. QQQ is an equity ETF, so in terms of positive drift it's the same as a stock (unless the stock is Enron, lol). A bond ETF should be okay, though I'm not sure about junk bonds. I do see Gold and Silver in there, so that's cool. All I'm saying is I've seen another vid on this channel bring up the subject of positive drift, so in other vids Forex and/or other non-equity assets were included in the tests. I was just wondering about this particular vid. Any decent test should IMO compare results against buy & hold. Love this channel so far. :)
@federicomilani53676 күн бұрын
This is a fantastic video, great job! Keep up the amazing work! It’s truly unfortunate that some people leave scam comments under such a valuable and well-crafted video. Your content deserves nothing but admiration and respect!
@CodeTradingCafe5 күн бұрын
Thank you so much for your support!
@Kripik7 сағат бұрын
Heres an idea try a strategy based on breadth indicators
@lorensaunders60345 күн бұрын
I absolutely love this.
@CodeTradingCafe5 күн бұрын
me too actually :) Thank you for your comment!
@cartilo26193 сағат бұрын
my goat is back with the educational content
@namesanddames5 күн бұрын
Definetly interesting, worth try on other emea markets. but the thing is how could be more succesful than the “predicting market direction” strategies? I guess random walk effect is highly stronger than we expect. I am losing faith in indicators 😂 I will share my results after testing them. Thank you for all code styling and approach 🙏💪🏻
@CodeTradingCafe3 күн бұрын
Hi, thank you. Actually this video doesn't show that random is better than predicting the market. But it shows that risk management is crucial and it can make a strategy profitable even if you didn't guess the market right. I mean honestly this is not new but to see it in numbers is good. In my opinion the best would be combining both, a good indicator/confirmation and risk management together.
@jm74765 күн бұрын
Great video, thanks!!
@CodeTradingCafe3 күн бұрын
Glad you liked it! Thank you for your support.
@Simran_Patel_123Күн бұрын
Best platform ?
@NeeshaGaikwadКүн бұрын
Trading
@Simran_Patel_123Күн бұрын
@NeeshaGaikwad forex fx
@NeeshaGaikwadКүн бұрын
@Simran_Patel_123then you can try winprofx
@CodeTradingCafeКүн бұрын
It depends on your geolocation, try asking around you for this, it's better.
@sukantasaha30345 күн бұрын
I always appreciate the way you explain codes.
@CodeTradingCafe3 күн бұрын
Thank you, it's really good to know.
@ashokkumar23425 күн бұрын
Great Video
@CodeTradingCafe5 күн бұрын
Glad you enjoyed it, thank you for your support!
@abdsh4225 күн бұрын
It's been some time since I watched your videos. I think I have a big list to recap. Hahaha! I really enjoyed them.
@CodeTradingCafe3 күн бұрын
Welcome back! Actually I remember last time you left a detailed technical comment that I still kept a copy of in my documents :)
@abdsh422Күн бұрын
@@CodeTradingCafe
@Trizzer895 күн бұрын
How many trades and commissions?
@CodeTradingCafe3 күн бұрын
Commissions are set to 0.0002 (as per the recommendation of Backtesting documentation but this is for forex spread) I tried to increase to 0.0005 results don't change because daily timeframe has wide price range and so trades wins cover easily for spread and commissions, the problem becomes challenging if you are trying lower timframes.
@nawaz_haider6 күн бұрын
Similer to NNFX Trade Management. Cool stuff.
@CodeTradingCafe5 күн бұрын
trade management is usually left aside by beginners but it's half of the trading effort.
@enricomarangoni3304 күн бұрын
Hi, nice video as always but Im wondering if you ever put these ideas to work in a live market, It would be nice to see some theory applied to a real capital (nowadays there are platform that allows to start with small things). It seems to me that all these ideas work in the code but the actual environment would be totally different (especially in the downside). But keep up the good work!
@CodeTradingCafe3 күн бұрын
Hi, definitely worth it, I can tell you out of experience, usually strategies on daily timeframe have higher chances to continue working on live data, however lower timeframes are more challenging mainly profits are eaten by fees, slippage and spread.
@ZyzzxZyzzx-m4s4 күн бұрын
Thanks for your videos. Pls can you make a full video from writing and backtesting a bot like this to deployment on cloud?
@CodeTradingCafe3 күн бұрын
It might be a very long video, but also it depends on your geolocation because some brokers have different types of accounts depending on local laws.
@ZyzzxZyzzx-m4s3 күн бұрын
@@CodeTradingCafe okay. Thank you
@ZyzzxZyzzx-m4s3 күн бұрын
@@CodeTradingCafe I’m finding it difficult deploying it bc my bot fetch live data from mt5 for the analysis . So mt5 needs to be always on before the bot can work. The brokers available in my location doesn’t have api functionality
@CodeTradingCafe3 күн бұрын
I see did you mean a bot in python that also uses mt5 ?
@ZyzzxZyzzx-m4s3 күн бұрын
@@CodeTradingCafe yes. But can it be deployed?
@hakimbaouali92374 күн бұрын
can you provide a code which work in tradingview.thanks
@CodeTradingCafe3 күн бұрын
Hi, tradingview use pinescript language which I am not familiar with, you can translate some of my codes using chatGPT maybe it might be of help.
@shibilcmr4 күн бұрын
Can you run demo account mt5 platform at least next vide with this strategy
@CodeTradingCafe3 күн бұрын
Hi sorry I don't use mt5 nor mql5 not anymore :)
@shibilcmr3 күн бұрын
@CodeTradingCafe then which pllatfoam you use
@shibilcmr2 күн бұрын
@@CodeTradingCafe then your platform?
@CodeTradingCafeКүн бұрын
Python for signals and the rest it depends if I am at my desk or phone (Phone is just for monitoring not trading)
@RaoKazimAli-q5c10 сағат бұрын
Good 😊 can you make a futures trading strategy for the price action or any other way to do a very short timeframe scalping like for 1min 3min 5min or last 15min
@attris_wolf6 күн бұрын
new video, nice )
@CodeTradingCafe5 күн бұрын
Thanks for the visit :)
@waow709021 сағат бұрын
Hey I am trying to build a machine learning python trade signal bot that will try to predict if the market will move up or down for the next minute. But I am so new to this and don't literally know what to do. Is there any advice you can give me or a source that could teach me?
@CodeTradingCafe16 сағат бұрын
Sources plenty, but my advise is to learn for the long term, give yourself a year of learning then progress to coding strategies otherwise it might be frustrating and you risk dropping your projects.
@subbaraoballipale8904 күн бұрын
pls cover CRP & pivot points Franklin O. Ochoa
@CodeTradingCafe3 күн бұрын
I will add it to my list, hopefully it's a good one :)
@divotiontogod3 күн бұрын
If risk management was a thing that could be followed - one would have been out of the market soon after a 20% drawdown and never entered back again! No matter you start with 1% or 0.1% when you are losing more than winning your capital will start drawing down no matter what
@CodeTradingCafeКүн бұрын
Risk and trade management are the most important factors that can keep the odds on your side. 20% drawdown is because the leverage is high so the risk is high and it's not as managed as it should be, it's just presented here as an experiment.
@carlomigs5 күн бұрын
it shows max_drawdown = min([r["Max. Drawdown [%]" for r in results]) in both the vid and the code from the download link. shouldn't it be max_drawdown = max... instead? thanks
@CodeTradingCafe3 күн бұрын
Hi, well spotted, but no actually because drawdown is a negative number so we need to get its minimum value (its most negative value).
@ctrodrums3 күн бұрын
I waitied until the end to see the equity curve, lol
@CodeTradingCafeКүн бұрын
Sorry and it wasn't as impressive :)
@ctrodrumsКүн бұрын
@@CodeTradingCafe Well after all it’s random entry. Just to prove solid MM foundation and exits.
@efrainromero39595 күн бұрын
This works if you consider the market as totally random and can't be predicted. Actually this is nothing new and I really think could be the Holly Grial since profesional gamblers use an risk management approximation instead of looking for the perfect entry. There is plenty of "progression" strategies based on this concept to get the most from winning streaks when keep the loses under control. 👍🏼
@CodeTradingCafe3 күн бұрын
I agree this is not new, all trading books emphasize trade and risk management. This video only shows it a bit in numbers, straight experiment.
@frankdearr27725 күн бұрын
Great topic, thanks 👍
@CodeTradingCafe5 күн бұрын
Glad you liked it!
@DavidHughes-y7j4 күн бұрын
Once again the code you provide is broken and not the code you run. I like your premise and the video is nice - but please provide the code you finally run to save me hours correcting your code. FYI, when I run your code I get the same error shown on your screen at the 7:50 mark. You have clearly corrected it before continuing recording. I also have corrected it but I get dramatically different results than you. My correction is likely not the same as yours. I have applied the code you show in the video which is substantially different to that provided btw. Not being able to replicate your results puts a BIG shadow on your reputation.
@CodeTradingCafe3 күн бұрын
Dear David for the sake of my reputation :) I just downloaded the files from the link retested and everything is running well I got the results I was getting while making the video (the error you are referring to at 7:50 was solved by commenting the line "#tp_sl_ratio=[i for i in range(2, 3)]," but this was already corrected in the uploaded version). I suggest you redownload the code and run it as is the first time without any modifications just to make sure it's working. Concerning the results these are affected by the lot size (0.02 meaning 2%, you can increase up to 0.04 and the margin I suggest keeping 1/5 to limit the drawdown/risk) it should work. Here are the results of my backtest with the redownloaded files (and a lot size of 0.04): Aggregated Returns: 147.27% Number of Trades: 360 Maximum Drawdown: -20.40% Average Drawdown: -2.34% Win Rate: 44.22% Best Trade: 207.90% Worst Trade: -35.21% Average Trade: 1.44%
@trntzx005 күн бұрын
mind blowing
@CodeTradingCafe3 күн бұрын
Thank you for your comment :)
@HitAndMissLab5 күн бұрын
Phenomenal idea. Random entry strategies are used as a referecnce for tresting real value strategies. But I would like to suggest that you try the effect of scaling in and scaling out of position size, because these are often missed parts of risk management. In particular scaling-in actually works like noise canceling headphones because scaling-in effectively amplifies signals and leaves noise un-amplified. I know that scaling-in and out is bit hard to code, but it would be very interesting to see the outcome.
@CodeTradingCafe3 күн бұрын
Hi, thank you for sharing I think scaling is a great idea (I missed it in this video). We did code scaling out in previous videos (kzbin.info/www/bejne/fnTPqXaMq8uLeq8 at time 19:00) but not scaling in actually I find it more advanced somehow, mainly coding the decision when to scale in and by how much. I will probably make a video about this, wasn't really detailed on my channel so far. Thanks again!
@HitAndMissLab3 күн бұрын
@@CodeTradingCafe What I would say is that, for the benefit of completness, a video would be done where scalling-in and scalling-out should be done in the same video, just to make it easier to compare them and do pros and conns. Another very important thing is that in hte same video one should separately test scalling-in and scaling-out on breakout and meaan reversal strategies. Although one can guess it, but in the interest of testing rigour all x4 combinations should be done. This knowledge will pay off in spades when implemented in strategies developed in the near future. I'm guessing here but scalling in should have less impact on reversal strategies, while scaling-out will perform worst with breakout strategies because breakout strategies usually have low win rates, so scalling-out will accumulate large losses. But for the sake of the educational value for viewers this shoudl be proven with a tests.
@CodeTradingCafeКүн бұрын
Will put this on my list although it's a lot of work to explain (the code is relatively simple, planning the video is more challenging)
@HitAndMissLabКүн бұрын
@@CodeTradingCafe It is hard, but videos like this are worth the effort because they tend to rise your authority amongst your audience and they get lots of likes and comments so YT algo loves them. I get all your videos withing few minutes from release because of that.
@CodeTradingCafe16 сағат бұрын
It's on my list, hopefully I will free some time at some point.
@Ankush_1Bhardwaj4 күн бұрын
Any forex trader here? Plz recommend me a reliable broker
@Sambhav-S4 күн бұрын
WinprofFX is great 👍
@Sambhav-S3 күн бұрын
You can give it a try
@CodeTradingCafe3 күн бұрын
The best is to ask in your area because brokers have different platforms depending on you geolocation.
@leisurehubb2223 күн бұрын
Exness
@monela26965 сағат бұрын
Why are you doing that? Seriously, is it some kind of weird hobby or you hope to magically make some money once day?
@agamtyxgi6 күн бұрын
hey just curious if you got my email :)
@CodeTradingCafe5 күн бұрын
I am getting so many emails really sorry if I drown :) afar