Download MetaTrader 5
To add comments, please log in or register
All MQL5.community events are grouped together. Have a look at the Wall!
Automated-Trading
Admin
94444
Automated-Trading 2010.09.21 11:20 

ytg_Percent_Lot:

The script calculates the number of lots to trade using the specified percentage of risk funds.

Author: Yuriy Tokman

ytg_Percent_Lot

Roger Flatt
22
Roger Flatt 2010.09.22 17:03  

Hi, Yuri

My philosophy is a little different, RISK = MAXIMUM LOSS.

 

First of all, I think that the calculation must take into account your stoploss level.

Consider two trades placed by two traders at the same time:

Trader A:  Buy 1.00 Lot, STP @20 Pips.

Trader B:  Buy 1.00 Lot, STP @40 Pips.

Trader B has twice as much risk, so for the same risk as Trader A, he must trade 0.5 LotSize.

 

Leverage must also be taken into account, if for example it is at 100.00, then profits and losses are at x100 level. The 'At Risk' is in money, it must be translated into Lots. Leverage MUST be accounted for.

If $2,000 at risk is sensible, then if leverafe is 100, the LotSize must also be divided by 100.00.

 

I also do not think it is good practice to use 'free margin' as a basis for the calculation. If you are at maximium exposure, and a trade moves against you, your margin is negative. Bad Thing!

 

//FreeMoney=AccountInfoDouble(ACCOUNT_FREEMARGIN);  // NOT SAFE!!

FreeMoney=AccountInfoDouble(ACCOUNT_BALANCE);       // SAFE

 

LotSize = (FreeMoney*AtRisk%) / AccountInfoInteger(ACCOUNT_LEVERAGE) / STP) 

USD 9997, At Risk 33.33%, STP 20, Leverage 100 gives a Lot Size of 1.60

 

Hope this makes sense?

T.

/
To add comments, please log in or register