# How to Calculate Lot Sizes and Risk Pricing with MQL4 and MQL5

If you are trading with a risk management approach then you need to calculate the amount you are prepared to risk and from that the lot size to trade if you have a fixed stop loss or the stop loss price if you want to fix lot sizes.

The calculations are really very simple and in this vide I show how you can calculate the value of a one point price movement and then use that value to calculate lot sizes or stop loss prices.

1. Mahdi Djawadi says:

After entring this section geting error which is riskLots & riskAmount & riskPoints variables are already defined
am i missing some thing Sir ?
———————————-
void Test(string symbol) {

PrintFormat(“Base currency is %s”, AccountCurrency());
PrintFormat(“Testing for symbol %s”, symbol);

double pointValue = PointValue(symbol);

PrintFormat(“ValuePerPoint for %s is %f”, symbol, pointValue);

// Situation 1, fixed lots and stop loss points, how much is at risk
double riskPoints = 75; // 0.0075 foR EURJPY, 0.00075 for EURGBP and AUDZND
double riskLots = 0.60;
double riskAmount = pointValue*riskLots*riskPoints;
PrintFormat(“Risk amount for %s trading %f lots with risk of %f points is %f”,
symbol, riskLots, riskPoints, riskAmount);

// Situation 2, fixed lots and risk amount, how many points to set stop loss

double riskLots = 0.60;
double riskAmount = 100;
double riskPoints = riskAmount/(pointValue*riskLots);
PrintFormat(“Risk points for %s trading %f lots placing %f at risk is %f”,
symbol, riskLots, riskAmount, riskPoints);

// Situation 3, fixed risk amount and stop loss, how many lots to trade

double riskAmount = 100;
double riskPoints = 50;
double riskLots = riskAmount/(pointValue*riskPoints);
PrintFormat(“Risk lots for %s value %f and stop loss at %f points is %f”,
symbol, riskAmount, riskPoints, riskLots);

}

1. ajm says:

Sections of the code are duplicated to show different situations. You will get errors if you compile without commenting out the other sections.
The code on github is modified to avoid this.

2. behzad.gsh says:

hi and thank you for sharing this viedio . but not work in xagusd how can i fix it?

1. ajm says:

Replied earlier

3. behzad.gsh says:

hi thank you for sharing this video.

i use for xagusd but not work it hoe fix it?

thanks.

1. ajm says:

You will have to give more detail on the problem. XAGUSD works in my tests.