-
Risk depends on your initial stop loss, lot
size, and the value of the pair. It does not depend on margin and leverage.
- 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.
- 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.)
- 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 - You must normalize lots properly and check against min and max.
- 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.
- Search for a GUI/Trade Assistant EA like mine (for MT 4): 'Money Manager Graphic Tool' indicator by 'takycard' - Risk Management - Articles, Library comments - MQL5 programming forum - Page 6 #55
Here is my solution for others to enjoy. Btw, the Trade Assistant EA that is on the market has wrong calculations.
double LotSizeHelper::FindLotSize(int stopLossPips = 50, double riskPercentage = 1) { // e.g. £10 = £1000 * 1% double maxRiskAmount = AccountBalance() * riskPercentage / 100; // e.g. 20 pence = £10 / 50 double riskPerPip = maxRiskAmount / stopLossPips; double pipValue = 10 * MarketInfo(Symbol(), MODE_TICKVALUE); double lot = riskPerPip / pipValue; // _numberOfDecimal is based on the min_lot e.g. 2 if min lot is 0.01 return NormalizeDouble(lot, _numberOfDecimal); }
way easier you can use the TickValue
How? Could you rewrite the method with the way you think is way easier and achieve same result?
Looking into it in more details, my understanding is TickSize is the minimum price movement which would be equal to Point for that market e.g. 0.00001 for EURUSD and 0.001 for USDJPY.
TickValue is the point value of the asked market in the deposit currency So
Pip Value = 10 * MarketInfo(Symbol(), MODE_TICKVALUE);
Correct?
Lot size = (Risk Amount/Stop loss points) / Tick value
For example: you have a $10'000 account and you trade EURUSD with a SL of 100 pips (1000 points with a 5 digit broker) and want to risk 1% ($100).
Your size will be = 100 / 1000 / 1 = 0.1
Remember to always check LOT_MIN, LOT_MAX and normalize value to LOT_STEPHere is my solution for others to enjoy. Btw, the Trade Assistant EA that is on the market has wrong calculations.
If you want reliable code you need to check for pipValue!=0 otherwise you are risking a divide by zero error.
It may happen MarketInfo(Symbol(), MODE_TICKVALUE) returns 0.
The question of lot size, pip size, pip value, etc, appears all over the place. Frequently when newbies ask questions, the answer is, "Read the Manual". I started programming in 1978. I have used COBOL, DIBOL, MUMPS, C, Basic, Natural, ADABAS, Oracle, PowerBuilder, JavaScript, Perl and a few other languages. MetaTrader is the worst to find the documentation you are looking for.
Isn't it about time MetaTrader provided a standard interface we can all use between EA and Broker so we don't have to waste vast amounts of time reinventing the wheel ?
I think you may be misunderstanding a few things.
The usual questions about lot size, pip size, pip value, etc. is not about MQL or even about MetaTrader or any software application at all. It is knowledge that is inherent to trading itself and these concepts existed long before computers even came into play.
This knowledge needs to be acquired form other sources and training material. When the response to such questions is "read the manual", it is under the assumption that such knowledge is already known and that one only needs to know how to apply them in the MQL language and on the MetaTrader platform, and not a need to be taught what they are about.
So, with all due respect, MetaQuotes has no obligation to teach "trading", just as Microsoft has no obligation to teach "accounting" or "management" to those using their business software.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Assume the account balance is £1000 in GBP.
I'd like to buy a 5 digit market such as EURUSD (1.11270) with 50 pips (500 points) but only risk 1% so 50 pips = £10
so every pip should be worth or cost 20 pence for me.
So what is the formula to calculate the lot sizing so that each pip cost me 20 pence for the above example?
similarly what formula should be used for markets with 3 digits like USDJPY (e.g. 109.493) so that each pip cost me 20 pence only.
I've written the below that works but not sure how to find the exchange rate for the counter currency? e.g. CHFGBP when trading EURCHF with GBP as base or e.g. USDEUR when trading EURUSD with GBP as base.