Stop Predicting the Market: How Risk Management in Trading Achieved 160% Gains (7-Year Backtest)

  Рет қаралды 28,696

CodeTrading

CodeTrading

Күн бұрын

Пікірлер: 113
@Audem_ars
@Audem_ars 5 күн бұрын
Dude the issue is you're essentially building a hfts and back testing it without accounting for platform fees or spreads
@maxnator
@maxnator 4 күн бұрын
You can just multiply the profits by a factor based on lotsize to account for commissions and spreads.
@CodeTradingCafe
@CodeTradingCafe 3 күн бұрын
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
@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
@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?
@monela2696
@monela2696 5 сағат бұрын
Did you seriously call Daily chart hft?
@beliebigerusername
@beliebigerusername 5 күн бұрын
i really like your videos - so high in quality and clean in insight and code!
@CodeTradingCafe
@CodeTradingCafe 3 күн бұрын
Happy to hear that! I appreciate your support.
@TheEcherriman
@TheEcherriman 5 күн бұрын
Once again, thank you for your expertise and generosity
@CodeTradingCafe
@CodeTradingCafe 5 күн бұрын
So nice of you, thank you for your support!
@billmietelski
@billmietelski 6 күн бұрын
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-wg7br
@Peter-wg7br 5 күн бұрын
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.
@gvidalcantavella
@gvidalcantavella 5 күн бұрын
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_Dicky
@Ricky_Micky_Dicky 5 күн бұрын
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.
@lorensaunders6034
@lorensaunders6034 5 күн бұрын
@@gvidalcantavella shorts are generally more profitable in a shorter time frame on a per trade basis but over the long term not so much.
@billmietelski
@billmietelski 5 күн бұрын
@@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. :)
@federicomilani5367
@federicomilani5367 6 күн бұрын
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!
@CodeTradingCafe
@CodeTradingCafe 5 күн бұрын
Thank you so much for your support!
@Kripik
@Kripik 7 сағат бұрын
Heres an idea try a strategy based on breadth indicators
@lorensaunders6034
@lorensaunders6034 5 күн бұрын
I absolutely love this.
@CodeTradingCafe
@CodeTradingCafe 5 күн бұрын
me too actually :) Thank you for your comment!
@cartilo2619
@cartilo2619 3 сағат бұрын
my goat is back with the educational content
@namesanddames
@namesanddames 5 күн бұрын
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 🙏💪🏻
@CodeTradingCafe
@CodeTradingCafe 3 күн бұрын
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.
@jm7476
@jm7476 5 күн бұрын
Great video, thanks!!
@CodeTradingCafe
@CodeTradingCafe 3 күн бұрын
Glad you liked it! Thank you for your support.
@Simran_Patel_123
@Simran_Patel_123 Күн бұрын
Best platform ?
@NeeshaGaikwad
@NeeshaGaikwad Күн бұрын
Trading
@Simran_Patel_123
@Simran_Patel_123 Күн бұрын
​@NeeshaGaikwad forex fx
@NeeshaGaikwad
@NeeshaGaikwad Күн бұрын
​@Simran_Patel_123then you can try winprofx
@CodeTradingCafe
@CodeTradingCafe Күн бұрын
It depends on your geolocation, try asking around you for this, it's better.
@sukantasaha3034
@sukantasaha3034 5 күн бұрын
I always appreciate the way you explain codes.
@CodeTradingCafe
@CodeTradingCafe 3 күн бұрын
Thank you, it's really good to know.
@ashokkumar2342
@ashokkumar2342 5 күн бұрын
Great Video
@CodeTradingCafe
@CodeTradingCafe 5 күн бұрын
Glad you enjoyed it, thank you for your support!
@abdsh422
@abdsh422 5 күн бұрын
It's been some time since I watched your videos. I think I have a big list to recap. Hahaha! I really enjoyed them.
@CodeTradingCafe
@CodeTradingCafe 3 күн бұрын
Welcome back! Actually I remember last time you left a detailed technical comment that I still kept a copy of in my documents :)
@abdsh422
@abdsh422 Күн бұрын
@@CodeTradingCafe
@Trizzer89
@Trizzer89 5 күн бұрын
How many trades and commissions?
@CodeTradingCafe
@CodeTradingCafe 3 күн бұрын
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_haider
@nawaz_haider 6 күн бұрын
Similer to NNFX Trade Management. Cool stuff.
@CodeTradingCafe
@CodeTradingCafe 5 күн бұрын
trade management is usually left aside by beginners but it's half of the trading effort.
@enricomarangoni330
@enricomarangoni330 4 күн бұрын
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!
@CodeTradingCafe
@CodeTradingCafe 3 күн бұрын
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-m4s
@ZyzzxZyzzx-m4s 4 күн бұрын
Thanks for your videos. Pls can you make a full video from writing and backtesting a bot like this to deployment on cloud?
@CodeTradingCafe
@CodeTradingCafe 3 күн бұрын
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-m4s
@ZyzzxZyzzx-m4s 3 күн бұрын
@@CodeTradingCafe okay. Thank you
@ZyzzxZyzzx-m4s
@ZyzzxZyzzx-m4s 3 күн бұрын
@@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
@CodeTradingCafe
@CodeTradingCafe 3 күн бұрын
I see did you mean a bot in python that also uses mt5 ?
@ZyzzxZyzzx-m4s
@ZyzzxZyzzx-m4s 3 күн бұрын
@@CodeTradingCafe yes. But can it be deployed?
@hakimbaouali9237
@hakimbaouali9237 4 күн бұрын
can you provide a code which work in tradingview.thanks
@CodeTradingCafe
@CodeTradingCafe 3 күн бұрын
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.
@shibilcmr
@shibilcmr 4 күн бұрын
Can you run demo account mt5 platform at least next vide with this strategy
@CodeTradingCafe
@CodeTradingCafe 3 күн бұрын
Hi sorry I don't use mt5 nor mql5 not anymore :)
@shibilcmr
@shibilcmr 3 күн бұрын
@CodeTradingCafe then which pllatfoam you use
@shibilcmr
@shibilcmr 2 күн бұрын
@@CodeTradingCafe then your platform?
@CodeTradingCafe
@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-q5c
@RaoKazimAli-q5c 10 сағат бұрын
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_wolf
@attris_wolf 6 күн бұрын
new video, nice )
@CodeTradingCafe
@CodeTradingCafe 5 күн бұрын
Thanks for the visit :)
@waow7090
@waow7090 21 сағат бұрын
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?
@CodeTradingCafe
@CodeTradingCafe 16 сағат бұрын
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.
@subbaraoballipale890
@subbaraoballipale890 4 күн бұрын
pls cover CRP & pivot points Franklin O. Ochoa
@CodeTradingCafe
@CodeTradingCafe 3 күн бұрын
I will add it to my list, hopefully it's a good one :)
@divotiontogod
@divotiontogod 3 күн бұрын
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
@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.
@carlomigs
@carlomigs 5 күн бұрын
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
@CodeTradingCafe
@CodeTradingCafe 3 күн бұрын
Hi, well spotted, but no actually because drawdown is a negative number so we need to get its minimum value (its most negative value).
@ctrodrums
@ctrodrums 3 күн бұрын
I waitied until the end to see the equity curve, lol
@CodeTradingCafe
@CodeTradingCafe Күн бұрын
Sorry and it wasn't as impressive :)
@ctrodrums
@ctrodrums Күн бұрын
@@CodeTradingCafe Well after all it’s random entry. Just to prove solid MM foundation and exits.
@efrainromero3959
@efrainromero3959 5 күн бұрын
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. 👍🏼
@CodeTradingCafe
@CodeTradingCafe 3 күн бұрын
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.
@frankdearr2772
@frankdearr2772 5 күн бұрын
Great topic, thanks 👍
@CodeTradingCafe
@CodeTradingCafe 5 күн бұрын
Glad you liked it!
@DavidHughes-y7j
@DavidHughes-y7j 4 күн бұрын
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.
@CodeTradingCafe
@CodeTradingCafe 3 күн бұрын
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%
@trntzx00
@trntzx00 5 күн бұрын
mind blowing
@CodeTradingCafe
@CodeTradingCafe 3 күн бұрын
Thank you for your comment :)
@HitAndMissLab
@HitAndMissLab 5 күн бұрын
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.
@CodeTradingCafe
@CodeTradingCafe 3 күн бұрын
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!
@HitAndMissLab
@HitAndMissLab 3 күн бұрын
@@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
@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
@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.
@CodeTradingCafe
@CodeTradingCafe 16 сағат бұрын
It's on my list, hopefully I will free some time at some point.
@Ankush_1Bhardwaj
@Ankush_1Bhardwaj 4 күн бұрын
Any forex trader here? Plz recommend me a reliable broker
@Sambhav-S
@Sambhav-S 4 күн бұрын
WinprofFX is great 👍
@Sambhav-S
@Sambhav-S 3 күн бұрын
You can give it a try
@CodeTradingCafe
@CodeTradingCafe 3 күн бұрын
The best is to ask in your area because brokers have different platforms depending on you geolocation.
@leisurehubb222
@leisurehubb222 3 күн бұрын
Exness
@monela2696
@monela2696 5 сағат бұрын
Why are you doing that? Seriously, is it some kind of weird hobby or you hope to magically make some money once day?
@agamtyxgi
@agamtyxgi 6 күн бұрын
hey just curious if you got my email :)
@CodeTradingCafe
@CodeTradingCafe 5 күн бұрын
I am getting so many emails really sorry if I drown :) afar
GPT: KAMA Scalping Strategy in Python Makes 795%
21:00
Algo-trading with Saleh
Рет қаралды 28 М.
🔴 The MOTHER of All Indicators (Dangerously Effective.....)
16:55
Jaidarman TOP / Жоғары лига-2023 / Жекпе-жек 1-ТУР / 1-топ
1:30:54
Какой я клей? | CLEX #shorts
0:59
CLEX
Рет қаралды 1,9 МЛН
Andro, ELMAN, TONI, MONA - Зари (Official Music Video)
2:50
RAAVA MUSIC
Рет қаралды 2 МЛН
The 8 AI Skills That Will Separate Winners From Losers in 2025
19:32
Generative AI in a Nutshell - how to survive and thrive in the age of AI
17:57
Convert TradingView Indicators into Strategies with AI (IT FINALLY WORKS)
21:49
Trading with Python: Simple Scalping Strategy
13:47
CodeTrading
Рет қаралды 108 М.
Best AI Trading Tool - This is CRAZY
14:48
Jason Graystone
Рет қаралды 238 М.
How to Invest for Beginners in 2025
21:25
Mark Tilbury
Рет қаралды 1,1 МЛН
Jaidarman TOP / Жоғары лига-2023 / Жекпе-жек 1-ТУР / 1-топ
1:30:54