# Need moneymanagement LOT size formula based on SL and Account Risk!

760

Hi, i please need a code/ formula which resizes the lot size based on Account Risk % calculated by including the STOPLOSS, and taking in consideration that my account is in EUR.

What i have is this:

```extern double RISK=1;  //1% RISK
double LOT;

LOT = NormalizeDouble(AccountEquity()*RISK/10000,2);```

But this one doesnt consider the stoploss

So i found this one on google search

`lot=NormalizeDouble(AccountBalance( )*MaximumRisk/StopLoss/(MarketInfo(Symbol(), MODE_TICKVALUE)),2);`

And this one

```lot = Risk * AccountEquity() / MarketInfo(Symbol(), MODE_TICKVALUE) / Stop;
```

But none of this works, please help me fix them, or give me a better one, thanks!

15331

1. Account Balance * percent = RISK = (OrderOpenPrice - OrderStopLoss)*DIR * OrderLots * DeltaPerlot (Note OOP-OSL includes the SPREAD)
2. Do NOT use TickValue by itself - DeltaPerlot
3. You must also check FreeMargin to avoid stop out
280

```   double Spread=MarketInfo(Symbol(),MODE_SPREAD)/Q;
double Risk=(RiskPercent*AccountEquity())/100;//this means if your balance 1000\$ & RiskPercent=10% >> you going to risk 100\$
double lot=Risk/((StopLoss+Spread)*MarketInfo(Symbol(),MODE_TICKVALUE)*Q);//Make Sure to Define Your StopLoss & Q=10 in 5 digits or Q=1 in 4 Digits ```
15331

yousefh:, read the comment in my DeltaPerlot. Do NOT use tick value by itself.
760

yousefh:

Sorry its not good

WHRoeder:
1. Account Balance * percent = RISK = (OrderOpenPrice - OrderStopLoss)*DIR * OrderLots * DeltaPerlot (Note OOP-OSL includes the SPREAD)
2. Do NOT use TickValue by itself - DeltaPerlot
3. You must also check FreeMargin to avoid stop out

Ok i see your point, so here is my logic and calculation how i calculate the RISK %

Which in MQL4 code looks like this:

```extern double MYSTOPLOSS = 50;  // CUSTOM SL SIZE IN PIPS AFTER THE STOPLEVEL
extern double RISK =2; // 2% ACCOUNT RISK

double LOT =(AccountEquity()*RISK)/(100*(MarketInfo(Symbol(),MODE_STOPLEVEL)+MYSTOPLOSS)* Point *100000 );```

A simple 1 liner, nothing complicated, now please help me insert that DELTA stuff that you have been talking about, i know the formula is not complete so please help me.And please note that my account is in EURO so in most cases its the basic currency.

760

Help me please quick, I would like to finish this project before X-mas :)
15331

Proximus: Help me please quick, I would like to finish this project before X-mas :)

Did you bother to click on the links provided?
760

WHRoeder:

Did you bother to click on the links provided?

Yes i did, but i dont understand how you fit that into my equation, you said you need this:

```  MarketInfo(pair, MODE_TICKVALUE)
/ MarketInfo(pair, MODE_TICKSIZE) ```
But i dont understand how this helps my equation, because dividing these two numbers will give a big number instead of the ticksize...
5394

Proximus:

Yes i did, but i dont understand how you fit that into my equation, you said you need this:

But i dont understand how this helps my equation, because dividing these two numbers will give a big number instead of the ticksize...

Perhaps looking at it from a different angle might help.

760

ubzen:

Perhaps looking at it from a different angle might help.

WTF guys, shouldnt that be TICKVALUE * TICKSIZE instead of TICKVALUE /TICKSIZE ? I think there is a big mistake there

Just made a quick indicator which shows separate values, i guess the TICKVALUE * TICKSIZE is the appropriate one...

And note the demo account is in EUR so that is the base currency, while i did the same test with a USD account and there the POINT was equivalent to TICKVALUE * TICKSIZE because it measures the quote currency value.

Files:
165

If i have understand the question right this will do the job for you.

```for( i=0; i<=ot; i++ ) for( z=0; z<=10; z++ )
{
if( long_orders_array_ATF[i][z] > 0 )
for (zz=0; zz<=10; zz++)
{