How to calculate True Risk before sending an order ?

 

Hi, I recently had a bad experience with unadequate MM... Now I'm going to do it RIGHT.

Goal: Find lot size for a given true risk ( in $ or % of Balance)

so I know beforehand how many dollars (or %) will be lost if the worst happends

Given:

-Balance

-Leverage

-SL (fixed)

E.g. Say I have an account Balance of $2340,

-and I want to risk 10% ( thats $234) loss on this trade in the case SL gets triggered

-Leverage = 1:500

-EURUSD

-spread = 1.8pips

-swap (ignored)

-SL is the main variable in this equation, TP vill be dependant on SL selected


Suggestions as to how to calculate this as accurately as possible ?

You may want to have a look at my current MM scheme here: https://forum.mql4.com/21414

 
DayTrader:


-SL (fixed)


-SL is the main variable in this equation, TP vill be dependant on SL selected


You know what?

You probably want to re-word your post.

 
cloudbreaker:

You know what?

You probably want to re-word your post.

What I meant the order is sent with a fixed SL, no TS etc.

The SL will be determined by testing to work well. That SL is then a given value when calculating that lot size.

 

Risk$ = LotSize * SL


For a given fixed Risk$ based on your balance, eg $234, you have to:


1) Fix LotSize and calculate SL

2) Fix SL and calculate LotSize


So you cannot make both variables at the same time:


"Find lot size for a given true risk" and

"SL will be determined by testing"





 

Hi DayTrader,

I use those formulas, they may help you to figure out your MM.

1. To avoid broker StopOut

StopOut pips = ( Balance / 2 ) / (lots x 10) so your risk in pips should not be greater than the StopOut in pips.

Balance/2 : every broker I tried were using 50% on the account balance, but check with your broker to be sure.

Lots x 10 : for every open order ( x 10 when leverage = 100:1)

2. when you open an order the risk = sl(in pips) x Lots x 10

So you just have to check if the risk can be taken according to the broker's StopOut.

This is the basics to know if your risk is affordable because those formulas deal with the constraints imposed by your environment. A good starting point to build a MM according to what you want to do (the constraints your trading system will impose you = the constraints you will set to yourself).

Hope it helps.

Regards

 

To calculate the number of contracts to open in order to limit the potential loss to a % of your account balance I use the formula below.

This is used for EURUSD trading on a USD balance, valueperpip will need to be calculated for dollar prefix pairs and non dollar pairs.

extern int risk1 = 9;//your risk of loss a % of the account

//Money managrement
//Calculate the number of contracts for optimum risk
double Lots,spread ;
spread = Ask-Bid;//spread of the currency
//Print("Spread: ",spread);
double risk = risk1*0.01;
double valueperpip = 1;
double riskvalue = (risk*(AccountBalance( )));
double lossvalue = (StopLoss+(spread/Point))*valueperpip;
//Number of contracts=ROUND(((capital risk%)*(Capital/max positions))/(Stop loss x Value per pip))/10),2)
double contracts = NormalizeDouble(((riskvalue/lossvalue)/(10/pointfactor)),2);//the contract value will be limited to the potential maximum loss(stoploss) that equates to the risk% of total capital

 
Hello DayTrader,

have a look at my article about risk and MM which has been just published...

...Hope it will help you in your trading ;)


On the Long Way to Be a Successful Trader - The Two Very First Steps



Cheers!

 
Zypkin:
Hello DayTrader,

have a look at my article about risk and MM which has been just published...

...Hope it will help you in your trading ;)


On the Long Way to Be a Successful Trader - The Two Very First Steps



Cheers!



Your article was quite enlightening and put MM in a new perspective (for a guy who just lost the account due to poor MM).

I take it MarketInfo(Symbol(),MODE_TICKVALUE) will reflect the leverage currently in use ?

Only question now is how to get my EA to read SR levels in a reliable way so I can run some tests on this MM.

Have had a look at Pivot(SR) but that didn't even look worth trying.

Any suggestions ?

 

> MarketInfo(Symbol(),MODE_TICKVALUE) will reflect the leverage currently in use


Yes, it always takes into consideration Account's settings.


If by SR levels you mean how to chose your StopLoss then I have an answer for that... but you have to wait for the next article :)
Shortly... when buying/selling Basically you should look for the highest bottom/top of the movement preceding your opening... then add a bunch of pips to make sure the SL is not accidentally hit on a major retracement.
A typical SL is within range 50-100 pips... if it comes higher you should then look for SR levels at lower timeframes.

 

double stop = 100;

double Account_Percentage = 1;//or whatever % of your account you want to risk per trade.


lot = ( ( Account_Percentage * ( AccountBalance() / 100 ) ) / stop) / MarketInfo( Symbol(), MODE_TICKVALUE );

 
fxcourt:

double stop = 100;

double Account_Percentage = 1;//or whatever % of your account you want to risk per trade.


lot = ( ( Account_Percentage * ( AccountBalance() / 100 ) ) / stop) / MarketInfo( Symbol(), MODE_TICKVALUE );

Here's my function:

//+------------------------------------------------------------------+
//| Lot size computation. |
//+------------------------------------------------------------------+
double atRisk;
double LotSize(double SL_points, bool modifying = false) {
// This function computes the lot size for a trade.
// Explicit inputs are SL relative to bid/ask (E.G. SL=30*points,) and if
// returned lot size will be used in a new order or be used to modify an
// pending order (trade count-1.) Implicit inputs are the MM mode, the MM
// multiplier and currently filled or pending trade count (used to reduce
// available balance.) Mode, multiplier, adjusted account balance determined
// the maximum dollar risk allowed. StopLoss determines the maximum dollar
// risk possible per lot. Lots=maxRisk/maxRiskPerLot
////////////////////////////////////////////////////////////////////////////

double ab = AccountBalance();
switch(MMMode_F0M1G2) {
case 0: // fixed
atRisk = MMMultplier;
break;
case 1: // moderate
// See https://www.mql5.com/en/articles/1526 Fallacies, Part 1: Money
// Management is Secondary and Not Very Important.
atRisk = MathSqrt(MMMultplier * ab)/ab; // % used/trade ~const.
atRisk = MathSqrt(MMMultplier * ab * MathPow( 1-atRisk,
OrdersTotal()-modifying ));
break;
case 2: // geometrical
atRisk = MMMultplier * ab
* MathPow( 1-MMMultplier, OrdersTotal()-modifying );
break;
default:
atRisk = 0; Alert("TLEA Bad MMMode_F0M1G2");
break;
}

double maxLossPerLot = MathAbs(SL_points)/Point
* MarketInfo( Symbol(), MODE_TICKVALUE );
// IBFX demo reports EURUSD TICKVALUE=0.1 MAXLOT=50 LOTSIZE=10,000
// I expected 1.0 100,000
// In tester I had a sale: open=1.35883 close=1.35736 (0.00147) gain$=97.32
// $97.32/6.62 lots/147 points=$0.10/point.

double size = atRisk / maxLossPerLot;
double LotStep = MarketInfo( Symbol(),MODE_LOTSTEP );
int steps = (size+LotStep/2)/LotStep;
size = MathMin( steps*LotStep,
MarketInfo( Symbol(), MODE_MAXLOT ));
if (size < MarketInfo( Symbol(), MODE_MINLOT )) size = 0.0; // Risk limit.
if (size==0) Print( "LotSize(SL=", DoubleToStr(SL_points, Digits),")=", size,
" [",atRisk,"/",maxLossPerLot,
",AB=",ab,AccountCurrency(),
",mode=",MMMode_F0M1G2,
",mult=",MMMultplier,
",coat=",OrdersTotal(),
"]" );
atRisk = size * maxLossPerLot;
return(size);
}