Can I get some math help with this

Hello everyone.

Struggling with some math here and could use some help. Here’s what I’m trying to figure out.

I want to convert a percent of account balance to “units” for a trade. The MetaTrader 4 trading platform asks for “units” on a buy or sell. But I want to think in terms of % of my account balance, so I’m trying to come up with the formula to convert between the percentage and “units”.

For example (a hypothetical situation), I have a $1,000 balance in my account. I want to risk 2% of my account balance ($20) on a trade (long on GPB/USD at 2.0669 just as an example). My leverage is 100:1 (1%). I’m trading standard lots (100,000).

What is the formula for computing “units” for this trade (as required by MetaTrader 4 to execute my transaction) based on the figures provided? Do I have all of the figures I need to complete the formula?

Once I have a working formula for this, I can plug it into a spreadsheet and use it to calculate the “units” for a given trade based on my account balance and what % of that balance I want to risk on any given trade.

Thanks much for your help!

  • Iggy

OK, figured it out.

If anyone else might find this helpful, here it is:

Account Balance in $
-divided by-
Leverage of your account as a percent (ex. - 100:1 is 1% leverage; 50:1 is 2% leverage; 10:1 is 10% leverage; 1:1 is 100% leverage)
-divided by-
Base Currency (Bid Price for Sell transaction, Ask Price for Buy transaction)
-divided by-
Lot Size (100,000 for standard; 10,000 for mini; 1,000 for micro; 100 for nano; 1 for Oanda.com)
-times-
Amount of Account Balance to risk as a percent

Result is # of units for the trade you wish to execute.

Best,

  • Iggy

Actually, your risk is your Stop Loss, not the cost to get into the trade.

With a $1,000 balance, risking 2% on a standard lot (assuming $10/pip):

$20 (2% of account) / $10/pip = 2 pips risk (Stop Loss)

That wouldn’t even cover the spread. :slight_smile:

You can’t trade standard lots with a $1,000 account, anyway, because the cost to enter the trade will be more than your account balance when you take into consideration the maintenance margin requirement.

Now, do the same calculation for a mini lot @ $1/pip and a micro lot @ $0.10/pip and you get better numbers.

Hello,

This is my first post, and the first time I had something to contribute. I hope this will be helpful to someone out there.

This is a simple formula I use to choose how many lots to buy at 2% capital risk.

[I][(0.02c]/r]/x=y[/I]

c= initial capital
r= pips you are risking in .0001 per pip format
x= the lot size you are using
y= Amount of lots to buy

Example:
If I have 5000 in my trading account and I am trading mini-lots where I will be placing my stop at a loss of 40 pips:

0.02*5000=100
100/.004=2500
2500/10000=2.5

Therefore, since we buy ship .5 lots, I would enter the market buying or selling 2 lots, and will have remained within my 2% risk allowance.

GBLilleyUSMC

Hi Terry and GBLilleyUSMC,

Thank you both for your input. Both are very helpful. I didn’t realize the risk figures in the stop loss. I’m retooling my spreadsheet to account for this.

Much thank!

Hey GBLilleyUSMC,

Another quick question (well, a quick set of questions :)).

You say to use:

r= pips you are risking in .0001 per pip format

Where are you getting the .0001?
Does that assume a mini-lot size of 10,000?
If your account was using standard lot sizes, would the factor then be .00001?
Or is it truly a static factor regardless of lot size?

Thanks. I think I’m getting closer to my ideal formula.

Best,

  • Iggy

Figured it out.

It’s a static factor to determine value of pips based on lot size.

I’m beginning to understand the numbers better.

  • Iggy

Yaaarrrggghhh …

The formula breaks down when lot size = 1 (as it does with Oanda.com)

For example on an account with $1,000, a trade of 2% with a stop loss of 40 pips renders the following results:

.02 * $1,000 = $20
$20 / .004 = 5000
5000 / 1 = 5000 lots (or units in the case of Oanda.com)

To make that trade would tie up margin of $500 (of my margin of $10,000 on an account with 10:1 leverage), a risk of 50% of my capital.

Where am I going wrong here?

OK, I think I have it worked out.

From the example in my last post, I would tie up $500 of my $1,000 available capital.

But if my trade was stopped out due to a 40 pip dip (or spike on a short), I would only lose the $20.

Am I getting this?

Thanks again for your help.

Best,

  • Iggy

The $20 loss is correct, but the margin would depend on the currency pair you’re trading and the current price.

For Oanda it’s (price*units)/leverage

For example, if you’re trading the GBP/USD and the current price is 2.0500, then it would cost you:

10:1 leverage - (2.0500*5000)/10 = $1,025

20:1 leverage - (2.0500*5000)/20 = $512.50

50:1 leverage - (2.0500*5000)/50 = $205

I always add 50% to that cost to cover maintenance margin. Better safe than sorry.

The $20 loss will be the same either way as it isn’t dependent on your leverage.

Iggy,

When you divide by x, x = the lot size, not the number of lots. The reason this variable was included is because some people trade mini-lots or micro-lots. In my case I am currently trading mini lots therefore I would divide by 10,000 which is the lot size for a minilot.

I created this formula with GBPUSD in mind so for the GBPUSD one pip = .0001 so when I am talking about pips risked I would for example say 40 pips = .004

I’d be happy to answer anymore questions you may have; however, I am a newbie to the forex, but the math should work.

GBLilleyUSMC
Ben

I use an position size calculator in MT4. You can download it for free and it tells you exactly how big your position can be as a % of your account or from your equity Also calculates R:R