How do I calculate lot size? - page 3

 
chaffinsjc:

Let's say my mini account has margin of $10,000, and I want to risk 2% on the next trade (that is, simply use $200 to buy <some amount> of contracts).

[I realize this is a limited view of "risk". I'm not interested in stopLoss pips, or profit targets, or whatever.]

Using MetaTrader, I get the following mini account information from my broker:

accountLeverage = AccountLeverage(); // value = 200
modeLotSize = MarketInfo("EURUSDm", MODE_LOTSIZE); // value = 10000
modeLotStep = MarketInfo("EURUSDm", MODE_LOTSTEP); // value = .01
modeMinLot = MarketInfo("EURUSDm", MODE_MINLOT) ); // value = .01

QUESTION: How do I calculate the lot size for $200? (It would be useful to know the cost of a minimum size lot. In this case, the minimum size lot is .01).

QUESTION: Is the lot size calculation formula the same for all currency pairs?

Thank you very much in advance.


I send to you a good lot size calculator based on the equity and not on the balance. It's better if ou have more one trade.

 
I send to you my lot size calc. It's based on equity and not on Balance. It's better if you use more thant 1 trade together.
Files:
 

In the documentation :

MODE_TICKVALUE

16

Tick value in the deposit currency

MODE_TICKSIZE

17

Tick size in points


For my five digit broker : mode_tickvalue = 1; mode_ticksize = 0.00001

So why every body give this line : 

   double pipValue = MarketInfo(Symbol(),MODE_TICKVALUE);
 if (Digits==3 || Digits==5) pipValue *= 10;

Aint this wrong ?

 

This is wrong, missworded (?)

double pipValue = MarketInfo(Symbol(),MODE_TICKVALUE);
 if (Digits==3 || Digits==5) pipValue *= 10;

It should be : if Digits == 5 AND if you work in Pips, then  ....

if (Digits==3 || Digits==5) pipValue *= 10;

if someone work in Point, someone don't care about Pips.

 
ffoorr:

In the documentation :

MODE_TICKVALUE

16

Tick value in the deposit currency

MODE_TICKSIZE

17

Tick size in points


For my five digit broker : mode_tickvalue = 1; mode_ticksize = 0.00001

So why every body give this line : 

Aint this wrong ?

   double pipValue = MarketInfo(Symbol(),MODE_TICKVALUE);
 if (Digits==3 || Digits==5) pipValue *= 10;

 

 That is just for when people input values as pips. Point is not usually equal to 1 pip.
 
ffoorr:  Aint this wrong ?

There is Tick, PIP, and Point. They are all different in general. A tick is the smallest change of price. A Point is the least significant digit quoted. In currencies a pip is defined as 0.0001 (or for JPY 0.01)

On a 4 digit broker a point (0.0001) = pip (0.0001). [JPY 0.01 == 0.01] On a 5 digit broker a point (0.00001) = 1/10 pip (0.00010/10). Just because you quote an extra digit doesn't change the value of a pip. (0.0001 == 0.00010) EA's must adjust pips to points (for mq4.) In currencies a tick is a point. Price can change by least significant digit (1.23456 -> 1.23457)

In metals a Tick is still the smallest change but is larger than a point. If price can change from 123.25 to 123.50, you have a TickSize of 0.25 and a point of 0.01. Pip has no meaning.

This is why you don't use TickValue by itself. Only as a ratio with TickSize. See DeltaValuePerLot()

 
Roman Kramar:

The problem is not fully defined. If you say you want to risk 2% then you have to fix one of the variables: the stop loss level or the trade volume. Since you're asking about calculating the lot size that means you don't want it fixed but that requires you to become interested in stop loss pips even though you say you're not. If you don't have a stop loss then risking 2% means taking a fixed lot size, e.g. 1.0, and waiting till your current losses reach 2% of the initial margin. You don't need to calculate the lot size here as you see.


Once stop loss level enters the view, the calculation is simple:


double tradeVolume = AccountFreeMargin() * Risk/100 / ( StopLossPoints * MarketInfo( Symbol(), MODE_TICKVALUE ) );


That is, given a stop loss level for any particular trade, you will always have the specified percentage of your initial margin lost if the stop loss is taken.


You will also want to normalize the resulting value by MODE_LOTSTEP and cap it with MODE_MINLOT and MODE_MAXLOT.

How Can I calculate all my opened order size in USD ?

 
magonicolas: How Can I calculate all my opened order size in USD ?
  1. Don't double post! You already had this thread open.
              General rules and best pratices of the Forum. - General - MQL5 programming forum

  2. Makes no sense. How do I calculate my quart in USD?

    Never risk more than a small percentage of your account, certainly less than 2% per trade, 6% total to the account. Risk depends on your initial stop loss, lot size, and the value of the pair. It does not depend on margin and leverage.
    1. You place the stop where it needs to be — where the reason for the trade is no longer valid. E.g. trading a support bounce the stop goes below the support.
    2. AccountBalance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the spread, and DeltaPerLot is usually around $10/pip but it takes account of the exchange rates of the pair vs. your account currency.)
    3. Do NOT use TickValue by itself - DeltaPerLot and verify that MODE_TICKVALUE is returning a value in your deposit currency, as promised by the documentation, or whether it is returning a value in the instrument's base currency.
                MODE_TICKVALUE is not reliable on non-fx instruments with many brokers - MQL4 programming forum 2017.10.10
                Is there an universal solution for Tick value? - Currency Pairs - General - MQL5 programming forum 2018.02.11
                Lot value calculation off by a factor of 100 - MQL5 programming forum 2019.07.19
    4. You must normalize lots properly and check against min and max.
    5. You must also check FreeMargin to avoid stop out

    Most pairs are worth about $10 per PIP. A $5 risk with a (very small) 5 PIP SL is $5/$10/5 or 0.1 Lots maximum.

 
William Roeder:
  1. Don't double post! You already had this thread open.
              General rules and best pratices of the Forum. - General - MQL5 programming forum

  2. Makes no sense. How do I calculate my quart in USD?

    Never risk more than a small percentage of your account, certainly less than 2% per trade, 6% total to the account. Risk depends on your initial stop loss, lot size, and the value of the pair. It does not depend on margin and leverage.
    1. You place the stop where it needs to be — where the reason for the trade is no longer valid. E.g. trading a support bounce the stop goes below the support.
    2. AccountBalance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the spread, and DeltaPerLot is usually around $10/pip but it takes account of the exchange rates of the pair vs. your account currency.)
    3. Do NOT use TickValue by itself - DeltaPerLot and verify that MODE_TICKVALUE is returning a value in your deposit currency, as promised by the documentation, or whether it is returning a value in the instrument's base currency.
                MODE_TICKVALUE is not reliable on non-fx instruments with many brokers - MQL4 programming forum 2017.10.10
                Is there an universal solution for Tick value? - Currency Pairs - General - MQL5 programming forum 2018.02.11
                Lot value calculation off by a factor of 100 - MQL5 programming forum 2019.07.19
    4. You must normalize lots properly and check against min and max.
    5. You must also check FreeMargin to avoid stop out

    Most pairs are worth about $10 per PIP. A $5 risk with a (very small) 5 PIP SL is $5/$10/5 or 0.1 Lots maximum.

Im not talking about risk, I just want to know the amount in USD of Opened Orders.

 
magonicolas:

Im not talking about risk, I just want to know the amount in USD of Opened Orders.

Please STOP double posting !
Reason: