# Earn Forex Risk of Ruin Formula

Hi everyone,

There's a really good article on this site that explains different Risk of Ruin (ROR) calculations (https://www.earnforex.com/guides/risk-of-ruin-in-trading/).

The last one mentioned in the article is meant to calculate the ROR for a strategy that consists of different win/loss size, different probabilities which is the one that I want to use.

The article doesn't seem to explain what the N value is or how it is derived. In the article's example the value of 9 was inserted. Could someone tell me how this value is derived please?

I have a snapshot of some of the PHP code that I am referencing in the article and I have a link for it above.

Code:
```/*
Starting balance:      \$2,500.00
Target balance:        \$5,000.00
Loss probability:      30%
Win probability:       70%
*/

\$begin_state = 5;
\$N = 9;
\$loss_step = 3;
\$win_step = 2;
\$q = 0.3;
\$p = 0.7;
....```

Last edited by a moderator:

#### Enivid

Staff member
The \$N is the number of transitional states (k) from the description above that code in the article.
There was an error in that description - it mentioned that k = 11 for that example. In fact it should be 9.
I have fixed it now and also added commentaries to describe that portion of the PHP code.

Thank you for the quick reply! Changing the 11 to 9 clears it up as that is the number that is referenced in the code. It makes perfect sense now!

So for simplicity, is it safe to use the formula (Target Balance / GCD) - 1 to get to K?

Thanks again!

#### Enivid

Staff member
So for simplicity, is it safe to use the formula (Target Balance / GCD) - 1 to get to K?
Yes, that would be correct.

• Thank you sir!!

Replies
0
Views
937
Replies
10
Views
5K
Replies
1
Views
930
Replies
0
Views
1K
Replies
19
Views
9K