<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Dakshal Raijada</title>
    <description>The latest articles on DEV Community by Dakshal Raijada (@dakshal).</description>
    <link>https://dev.to/dakshal</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4199884%2F276c623a-5488-4b7c-8bbc-92cfd18bd8e6.jpg</url>
      <title>DEV Community: Dakshal Raijada</title>
      <link>https://dev.to/dakshal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dakshal"/>
    <language>en</language>
    <item>
      <title>Our Risk of Ruin Calculator Said 2%. Our Real Trades Said 11%.</title>
      <dc:creator>Dakshal Raijada</dc:creator>
      <pubDate>Thu, 22 Oct 2026 08:36:42 +0000</pubDate>
      <link>https://dev.to/dakshal/our-risk-of-ruin-calculator-said-2-our-real-trades-said-11-2b40</link>
      <guid>https://dev.to/dakshal/our-risk-of-ruin-calculator-said-2-our-real-trades-said-11-2b40</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://yuratrading.com/blogs/risk-of-ruin-calculator-check" rel="noopener noreferrer"&gt;YuRa Trading&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  A number that was too low
&lt;/h2&gt;

&lt;p&gt;We ran our free &lt;a href="https://yuratrading.com/tools/risk-of-ruin-calculator" rel="noopener noreferrer"&gt;risk of ruin calculator&lt;/a&gt; on the Asian Range Breakout, a strategy we backtested and now forward test at 1%&lt;br&gt;
risk per trade. We gave it the strategy's real averages from the backtest. It said the chance of the account ever falling 20% below where it started, over four years of trading, was about &lt;strong&gt;2%&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Then we ran the same question on the strategy's real trades. The answer was about &lt;strong&gt;11%&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The calculator was not broken. It did exactly what it was built to do. The&lt;br&gt;
problem is a simplifying assumption that almost every risk of ruin calculator makes, and it matters for a lot of real strategies. This post explains how the calculator works, how we checked it, and when you should not trust it.&lt;/p&gt;
&lt;h2&gt;
  
  
  What risk of ruin means
&lt;/h2&gt;

&lt;p&gt;Risk of ruin is the chance that a run of bad luck drags your account down to a level where you would give up, before your edge has time to pay off.&lt;/p&gt;

&lt;p&gt;"Ruin" here does not mean zero. Almost nobody keeps trading a strategy after it has cut their account in half. So you pick the drawdown you could not live with, for example 40% below your starting balance, and the calculator tells you how often the account touches that line.&lt;/p&gt;

&lt;p&gt;A strategy can make money on average and still have a high risk of ruin. The average only shows up over many trades. In the short run you get losing streaks, and if your trades are too big, a bad streak early on can do enough damage that you stop.&lt;/p&gt;
&lt;h2&gt;
  
  
  How the calculator works
&lt;/h2&gt;

&lt;p&gt;You give it five numbers: your win rate, how much a win pays compared with a loss (reward to risk), how much of your account you risk per trade, the&lt;br&gt;
drawdown you count as ruin, and how many trades to look ahead.&lt;/p&gt;

&lt;p&gt;It then plays out &lt;strong&gt;8,000 possible futures&lt;/strong&gt;. In each one:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The account starts at 1.0.&lt;/li&gt;
&lt;li&gt;For every trade, it rolls a random number. Below your win rate, the trade   wins and the account grows by your risk times your reward to risk. Otherwise it shrinks by your risk.&lt;/li&gt;
&lt;li&gt;Your stake is always a share of the account as it is now, not of where it started. After a loss you bet a little less, after a win a little more. This is called fixed-fractional sizing, and it is how most traders size.&lt;/li&gt;
&lt;li&gt;If the account touches the ruin line at any point, that future counts as
ruined.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The share of the 8,000 futures that got ruined is your risk of ruin.&lt;/p&gt;

&lt;p&gt;The random numbers come from a fixed seed. That means the same inputs always give the same answer, so anyone can check our numbers exactly.&lt;/p&gt;
&lt;h2&gt;
  
  
  How we checked it
&lt;/h2&gt;

&lt;p&gt;Monte Carlo gives an estimate, not an exact answer. So we checked it a second way that uses no random numbers at all.&lt;/p&gt;

&lt;p&gt;With fixed-fractional sizing, the account after any number of trades depends only on how many of them won and how many lost. That makes it possible to walk through every possible sequence of wins and losses, keep track of which ones hit the ruin line, and add up the exact probability.&lt;/p&gt;

&lt;p&gt;Here is what the calculator says next to the exact answer for a few setups:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Setup&lt;/th&gt;
&lt;th&gt;Calculator&lt;/th&gt;
&lt;th&gt;Exact&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;42% wins, 1.5 reward to risk, 2% risk, ruin at 40% down, 400 trades&lt;/td&gt;
&lt;td&gt;14.7%&lt;/td&gt;
&lt;td&gt;14.4%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Same, but 5% risk per trade&lt;/td&gt;
&lt;td&gt;61.6%&lt;/td&gt;
&lt;td&gt;60.0%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Same as the first, but 100 trades&lt;/td&gt;
&lt;td&gt;1.5%&lt;/td&gt;
&lt;td&gt;1.6%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Same as the first, but 1,000 trades&lt;/td&gt;
&lt;td&gt;23.4%&lt;/td&gt;
&lt;td&gt;23.4%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;45% wins, 1 to 1, 2% risk, ruin at 50% down, 500 trades&lt;/td&gt;
&lt;td&gt;87.8%&lt;/td&gt;
&lt;td&gt;87.9%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;55% wins, 2 to 1, 1% risk, ruin at 25% down, 500 trades&lt;/td&gt;
&lt;td&gt;0.0%&lt;/td&gt;
&lt;td&gt;0.0%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Every row is within normal Monte Carlo noise of the exact answer. The 5% row is the furthest off. Run with 200,000 futures instead of 8,000, it lands between 60.0% and 60.2%. So for the question it asks, the calculator is right.&lt;/p&gt;

&lt;p&gt;Both methods are open source, with these cases as tests, so you can check&lt;br&gt;
them yourself: &lt;a href="https://github.com/dakshalraijada/trading-risk-math" rel="noopener noreferrer"&gt;trading-risk-math on GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Two things in that table are worth a second look. Going from 2% to 5% risk&lt;br&gt;
per trade, with the exact same strategy, takes the chance of ruin from about 1 in 7 to more than half. And the longer you trade, the higher it gets, even with a positive edge, because a bad streak has more chances to turn up.&lt;/p&gt;
&lt;h2&gt;
  
  
  Where it goes wrong
&lt;/h2&gt;

&lt;p&gt;The calculator, like nearly every risk of ruin calculator, assumes that&lt;br&gt;
&lt;strong&gt;every win is the same size and every loss is the same size&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Real strategies are not like that. The Asian Range Breakout is a good example. Over 1,012 trades in our out-of-sample test (2022 to 2025, after costs):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;45.75% of trades won.&lt;/li&gt;
&lt;li&gt;The average win was &lt;strong&gt;+1.04%&lt;/strong&gt; of the account, and the average loss
&lt;strong&gt;-0.75%&lt;/strong&gt;. The loss is below the 1% risk because many trades close at the end of the session before they reach the stop.&lt;/li&gt;
&lt;li&gt;But the typical win was much smaller than the average: the median win was only &lt;strong&gt;+0.68%&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;A few big days did a lot of the work. The best single trade made &lt;strong&gt;+8.5%&lt;/strong&gt;,
and the top tenth of winning trades brought in &lt;strong&gt;36%&lt;/strong&gt; of all the money the wins made.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Feed the calculator the averages and it builds a strategy that wins +1.04%&lt;br&gt;
or loses -0.75%, every single time. That strategy is much smoother than the real one. Trade by trade, the real results swing about &lt;strong&gt;36% more&lt;/strong&gt;. Bigger swings mean deeper dips, and deeper dips mean more ruin.&lt;/p&gt;
&lt;h2&gt;
  
  
  What the real trades say
&lt;/h2&gt;

&lt;p&gt;Instead of averages, we took the 1,012 real trade results and drew them at&lt;br&gt;
random, over and over, to build tens of thousands of possible futures. A&lt;br&gt;
trade could be drawn more than once. This keeps the true mix of small wins, big wins and losses.&lt;/p&gt;

&lt;p&gt;At the strategy's real size of 1% risk per trade:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Question&lt;/th&gt;
&lt;th&gt;Calculator (same size wins and losses)&lt;/th&gt;
&lt;th&gt;Real trades, resampled&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Ever 20% down within 1 year (about 250 trades)&lt;/td&gt;
&lt;td&gt;1%&lt;/td&gt;
&lt;td&gt;6%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ever 20% down within 4 years (about 1,000 trades)&lt;/td&gt;
&lt;td&gt;2%&lt;/td&gt;
&lt;td&gt;11%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ever 30% down within 4 years&lt;/td&gt;
&lt;td&gt;0.2%&lt;/td&gt;
&lt;td&gt;3%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;We ran the resampling twice with different random seeds, and the answers&lt;br&gt;
matched to within half a percentage point.&lt;/p&gt;

&lt;p&gt;The conclusion about this strategy does not change. At 1% risk it is still a reasonable bet. But "about 1 in 9 chance of a 20% hole over four years" is a very different thing to plan for than "about 1 in 50".&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Update, 22 October 2026.&lt;/strong&gt; Arnold pointed out that closed trades leave out what happens while a trade is open: the account can dip further than where a trade finally closes. We re-ran the resampling with each trade's worst open loss included, measured from one-minute data with the same 1% sizing. The four-year chance of a 20% drop moves from 11.6% to 11.8-12.0%, and the one-year chance from 5.7% to 6.1-6.3%. The effect is small here because the 1% stop caps how deep an open trade can go. It would be much larger for a strategy without a hard stop, or one that holds several trades at once.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  Try it in code
&lt;/h2&gt;

&lt;p&gt;The calculator's maths is open source as a small TypeScript library with no dependencies: &lt;a href="https://github.com/dakshalraijada/trading-risk-math" rel="noopener noreferrer"&gt;trading-risk-math&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The exact check is a short dynamic program. The state is just "how many&lt;br&gt;
trades so far, how many of them lost", and any path that touches the ruin line is taken out of play:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// alive[k] = chance of k losses so far without ever touching the ruin line&lt;/span&gt;
&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fill&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;k&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;k&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;k&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;pr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;alive&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;k&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;pr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;continue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="c1"&gt;// a win keeps k losses, a loss moves to k + 1&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;up&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;k&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;dn&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="nx"&gt;k&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nx"&gt;ruinLevel&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;ruined&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;pr&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;k&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;pr&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;up&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;k&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;dn&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;k&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nx"&gt;ruinLevel&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;ruined&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;pr&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;k&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;pr&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;alive&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;alive&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;runRiskOfRuin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;exactRiskOfRuin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;runMonteCarlo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;parsePnl&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;trading-risk-math&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;params&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;winRate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;rr&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;1.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;riskPct&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;ruinPct&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;trades&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;400&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="nf"&gt;runRiskOfRuin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8000&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;riskOfRuin&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// 0.147, seeded so it is reproducible&lt;/span&gt;
&lt;span class="nf"&gt;exactRiskOfRuin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;riskOfRuin&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;     &lt;span class="c1"&gt;// 0.1435, no simulation&lt;/span&gt;

&lt;span class="c1"&gt;// for a strategy with lumpy wins, resample the real trade list instead&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;mc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;runMonteCarlo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;parsePnl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;myClosedTradePnls&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;mc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bootstrap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;probOfLoss&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Which number to use
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;If your wins and losses are fairly even in size&lt;/strong&gt;, for example a strategy with a fixed take profit and a fixed stop, the calculator is a good guide.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;If your profit comes from a few big winners&lt;/strong&gt;, which is common for
breakouts and trend following, the calculator will understate your risk.
Treat its answer as a floor, not a forecast.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;If you have a real trade list&lt;/strong&gt;, use it. Paste your closed trades into
our &lt;a href="https://yuratrading.com/tools/monte-carlo-simulator" rel="noopener noreferrer"&gt;Monte Carlo simulator&lt;/a&gt;. It resamples your actual results, so the uneven sizes are kept.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And whichever number you use, it still assumes your trades are independent&lt;br&gt;
and your edge stays the same. Real losing streaks tend to bunch up when&lt;br&gt;
market conditions change, so the true risk can be higher than either method shows.&lt;/p&gt;

&lt;p&gt;The simple lesson holds either way: your edge decides whether you make money, and your position size decides whether you are still trading when it pays off.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>statistics</category>
      <category>opensource</category>
      <category>trading</category>
    </item>
  </channel>
</rss>
