View Single Post
  #1097 (permalink)  
Old 09-17-2007, 08:27 AM
burn0050's Avatar
burn0050 burn0050 is offline
Member
 
Join Date: Feb 2007
Location: Denver, CO
Posts: 33
burn0050 is on a distinguished road
Unhappy Code

Quote:
Originally Posted by MrPip View Post
I understand what you are saying when you take the stoploss into account and rick means how much you are willing to lose.

You must have posted different code. The function I copied from your earlier post does not use stoploss anywhere. If risk is 10 it returns 10% of the account equity. For a 10K account it returns 1 lot. If the stoploss is 50 then the loss trade would be a max of $500 if there is no slippage. This is 5% of the account. That means an actual risk of 5%. The risk input is more like percent of account to trade.

Robert
Are you sure you are not talking about the code from nix (the autolot function)?

I posted the code into post 1046, which you quoted in post 1048:
http://www.forex-tsd.com/150350-post1048.html

This line:
double lotMM = ( AccountFreeMargin() * (accountRisk/100) )/( MarketInfo(Symbol(),MODE_TICKVALUE) * stopInPips );

As you see, "stopInPips" is used in the equation. This function: MarketInfo(Symbol(),MODE_TICKVALUE) returns the value of 1 pip when you have 1 lot.

Since you were a mathematical analyst, let's do some math:

For USD/JPY:
$25k free margin, with a 1.5% risk, 50 pip stop loss:
(25,000 * .015)/(8.68 * 50) = 375/434 = .86 lots

.86 lots * 8.68 = 7.47 pip value (1 pip = $7.47)
50 pips * $7.47 = $373.50 (due to rounding, not quite $375)

So, let's see what happens with a 100 pip stop loss:
(25,000 * .015)/(8.68 * 100) = 375/868 = .43 lots
.43 lots * 8.68 = 3.73 pip value (1 pip = $3.73)
100 pips * $3.73 = $373 (again, due to rounding, not quite $375)

No matter what stoploss you put in, the dollar amount risked remains constant for this size account using this risk percent. As your account size changes, so will the dollar amount risked, but the percent risked remains the same. The stoploss does not affect the percent risked, only how much currency you buy.

If you see fault with my calculations, please tell me.

Thanks,
burn0050
__________________
He who laughs last thinks slowest
Reply With Quote