Monte Carlo simulation saved me from taking a huge loss — Transcript
Full transcript
- 0:00Hey guys, it's so in this short video I
- 0:02want to show you a case where running
- 0:04Monte Carlo simulations helped me avoid
- 0:07a huge loss. And the thing is I did not
- 0:09expect that at all because normally when
- 0:11I use Monteol simulations I do it to see
- 0:14for example whether or not my strategy
- 0:16is overfit or considering my risk
- 0:18tolerance it helps me know how much
- 0:20position sizing I want to do. But the
- 0:22case that I'm talking about now has
- 0:24nothing to do with those. So let me show
- 0:26you what I mean. Now this is the
- 0:27strategy that I'm talking about. You see
- 0:29this equity curve? It looks awesome,
- 0:31right? It basically just keeps going up
- 0:33and up. Now it is for the Trump memecoin
- 0:35and the duration is almost 6 months and
- 0:39everything looks great. Now the penal is
- 0:4130% but with a max draw of minus 8%. Now
- 0:44considering my risk tolerance is usually
- 0:46minus 30%, that means I could have
- 0:48easily multiplied this by a number such
- 0:51as like three and then my P&L would have
- 0:54been near 100, right? So that would have
- 0:56been fantastic. But here's the thing,
- 0:59the win rate is 100%. Right? So it means
- 1:02basically it's never losing. And yes, it
- 1:05is a short only strategy. And the
- 1:07average holding time is 24 hours, which
- 1:09is a bit too high considering the time
- 1:12frame of the strategy was only 15
- 1:14minutes. And the sharp ratio was 2.55
- 1:17and the calmer ratio was 8. So this
- 1:20looks fantastic. But if you've been
- 1:22following me for a while, you know that
- 1:24recently I released this Monte Carlo
- 1:26feature, right? So when I ran it for
- 1:29this strategy just to make sure it's not
- 1:31overfit because the results are like too
- 1:34good to be true especially this 100% win
- 1:37rate. So that is definitely too good to
- 1:39be true and I wanted to see some losses
- 1:41because if the strategy has no losses I
- 1:44just cannot trust it because it
- 1:45basically means it's like a martingale
- 1:47strategy which we all know makes you a
- 1:50lot of money until you actually get
- 1:52liquidated right. So seeing a win rate
- 1:55of 100% is very scary and risky. Now let
- 1:58me show you the result of the Monte
- 2:00Carlo. So by the way, if you don't know
- 2:02how to run the script that I shared with
- 2:04you guys for a Monte Carlo, you
- 2:05basically put the code inside this file
- 2:08and it needs to be in the root of your
- 2:10project. And then in the terminal, you
- 2:12simply say Python and then the name of
- 2:14the file, which for me is test Monte
- 2:16Carlo, right? And inside this file, you
- 2:18want to make sure you've selected the
- 2:19correct symbol, exchange, the time
- 2:21frame, and the name of the strategy and
- 2:24the data routes in case you are using
- 2:26which this strategy is and also give it
- 2:28a starting or ending date, the number of
- 2:31scenarios you want to run and things
- 2:32like that. But anyways, let's go here.
- 2:35Now, this is the result. The original
- 2:37has a P&L of 30%, the sharp of 2.64, and
- 2:41the win rate of 100. exactly what I just
- 2:43displayed you from within the dashboard
- 2:45of the JC framework. But if we look at
- 2:47the best 5%, so it goes as well as 3.74.
- 2:51The MU rate is still 100%. In the
- 2:54median, the M win rate is 95%. So that's
- 2:57still really high and it looks
- 2:58wonderful. The sharp ratio for the
- 3:00median is 1.19. So again, this looks
- 3:03really, really awesome, right? But wait
- 3:05a minute, let's take a look at the
- 3:08chart. And this is how it looks like.
- 3:11Now, the thing is, most of them are
- 3:13indeed doing great. But some of them,
- 3:16not only they're not doing great, but
- 3:18they're actually going bananas. Like,
- 3:20this doesn't make any sense. The equity
- 3:23curve, even though it used to do really
- 3:25good, at some point it goes straight to
- 3:28zero. Some of them did good until here
- 3:30and then they went straight to zero. So,
- 3:33why is this happening? Because if the
- 3:35strategy has a stop-loss, which it does,
- 3:38this shouldn't be happening, right? So
- 3:39let's go to the code of the strategy.
- 3:41And you see when the position opens, I
- 3:44was submitting both the subplus and the
- 3:46take profit. But I also had this line.
- 3:48Now, by the way, this wasn't here. And
- 3:50that's actually what's wrong with it.
- 3:52Right? So we also had this line which is
- 3:54the update position method of Jesse,
- 3:57which basically means once another
- 3:59candle closes after I already have an
- 4:01open position, I want to do something.
- 4:03So in here, I'm checking if it's a short
- 4:05position, which it is because it's a
- 4:06short only position. I'm updating my
- 4:08stop loss. Now, when you do this,
- 4:10basically, you're creating some kind of
- 4:12trailing a stop, right? Because on every
- 4:13new candle, you're updating your stop
- 4:15loss. Now, remember this is short
- 4:17position, right? So, I want to bring
- 4:19down my stop loss. So, as soon as the
- 4:21price goes up again, I will close it,
- 4:23right? So, I'm using this syntax. So,
- 4:25the stops equals the quantity of the
- 4:27current position, which makes sense. And
- 4:29then as a price I'm saying the minimum
- 4:32of either the average stop loss which in
- 4:34this case means the previous stop loss
- 4:36price that we had. Now in the beginning
- 4:38we submitted here right? So for a short
- 4:41position the stop loss is being this. So
- 4:43the current price plus two times the
- 4:45ATR. But either this or if we've already
- 4:49updated it. So this will give us the
- 4:51average price. Now the average keyword
- 4:54here works only if you have multiple
- 4:56stops prices. But in this case we don't.
- 4:58We only have one, right? So again, it
- 5:01will give us that price and the big
- 5:02comma. Now the big comma is returning
- 5:04the values of the comma indicator with
- 5:07the period of 42. That's it basically.
- 5:10Now I was also selecting the current
- 5:12candles, but the syntax isn't really
- 5:14true. Like I could have just done this
- 5:16by the way because I'm using the same
- 5:18time frame. So this could have been just
- 5:20this. But anyways, I don't want to go
- 5:21through this exact syntax or entry or
- 5:23exit rules of the strategy. I just want
- 5:25to show this that basically I was
- 5:27updating my stop loss. So either this
- 5:30value which is like a moving average
- 5:32right and the average is stop price. So
- 5:36I I was just saying that give me
- 5:38whichever is lower. So why is this
- 5:40happening? So it goes really well but
- 5:42then it goes to zero right and the win
- 5:44rate is 100%. So I figured what's
- 5:47happening here. Basically I'm updating
- 5:50my stop loss price very soon after the
- 5:53position opens. So we can assume that
- 5:55this stop loss that we had here doesn't
- 5:57really matter and the new price was
- 6:00being either the previous price which of
- 6:02course would have been fine right or
- 6:05this become a value here so the only
- 6:07thing that could have caused things to
- 6:09go wrong was this and then I figured you
- 6:12see this is supposed to be a moving
- 6:13average so what if the value of it is
- 6:17actually below the current price and if
- 6:19that's happening then it is no longer a
- 6:22stop loss right so because if The
- 6:23current price is here and it's a short
- 6:26position. So your stop loss should
- 6:28always be high, right? For example, in
- 6:30here. But if you suddenly put it in
- 6:31here, then again it is no longer a stop
- 6:34loss, right? So it is a limit order. So
- 6:36it is waiting for the price to go here.
- 6:39So it will be your takeprofit order. But
- 6:41what if the price went up? Then your
- 6:45limit order will stay here forever. And
- 6:48because you keep getting losses then
- 6:52your equity curve will go to zero. So
- 6:54that was what was happening here. So the
- 6:56fix was to simply do this to add this
- 7:00value here to say if the big comma is
- 7:03bigger than the current price. I want to
- 7:06do this to make sure it is not below the
- 7:09current price. And when I did this then
- 7:12the equity curve went from this to this.
- 7:16So you see now instead of
- 7:20like 30% I'm making 5%. Although to be
- 7:24fair the max went down from - 8% to -4%.
- 7:29So it's still not that bad. In fact the
- 7:32win rate is still 70% which is good and
- 7:34the sharp ratio is 1.29 29 which again
- 7:37is good but it isn't this it's not like
- 7:41100% good anymore right and more
- 7:44importantly the strategy is safe to
- 7:46trade now so if you are using a
- 7:49technique like what I was doing in this
- 7:50strategy using a trailing stop-loss
- 7:53chances are you might also get some
- 7:55things wrong and maybe in your single
- 7:57back test you don't see that things are
- 8:00going wrong and Monte Carlo could
- 8:02actually save you from taking a huge
- 8:05loss at some point in the future. So
- 8:07that's it guys. I just wanted to share
- 8:08this experience with you because from
- 8:10now on I will never forget about this
- 8:13and I will definitely run Monte Carlo
- 8:15every single time before going live. Now
- 8:17this is a new type of video that I just
- 8:18did. So let me know what you guys think.
- 8:20If you enjoyed the video, please give it
- 8:22a like and subscribe to the channel for
- 8:24more videos like this. Thank you so much
- 8:25for watching. I'll see you in the next
- 8:27one.
- 8:32>> [music]
About this transcript
This page contains the full transcript of Monte Carlo simulation saved me from taking a huge loss by Algo-trading with Saleh, generated from the public captions YouTube serves with the video. The transcript has 1,632 words across 218 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.