//Money management. It calculates the lot size from the Stop Loss size and Risk input double GetLots(double RiskInPips) { double lot, dif; double MinLot; double MaxLot; double LotStep; double mpl; if(UseMoneyManagement) { double totalrisk = AccountBalance() * Risk / 100; double traderisk = totalrisk; double pip = traderisk/RiskInPips; lot = pip/MarketInfo(Symbol(), MODE_TICKVALUE); LotStep = MarketInfo(Symbol(),MODE_LOTSTEP); dif = MathMod(lot, LotStep); if(dif != 0) { lot -= dif; } } else { lot = Lots; } MinLot = MarketInfo(Symbol(), MODE_MINLOT); MaxLot = MarketInfo(Symbol(), MODE_MAXLOT); if(lot < MinLot) lot = MinLot; if(lot > MaxLot) lot = MaxLot; return(lot); }This Money management routine works.....It calculates lot size based on risk %, size in pips of SL, and account balance. It takes risk in pips as input which is either fixed or calculated by your trade algorythm, uses risk% which is an external variable and reads account balance. I use it with only 1 trade open at a time, but I see no reason it wouldn't work with multiple trades as it is not based on equity but account balance.
bluesman:
This Money management routine works.....It calculates lot size based on risk %, size in pips of SL, and account balance. It takes risk in pips as input which is either fixed or calculated by your trade algorythm, uses risk% which is an external variable and reads account balance. I use it with only 1 trade open at a time, but I see no reason it wouldn't work with multiple trades as it is not based on equity but account balance.
This Money management routine works.....It calculates lot size based on risk %, size in pips of SL, and account balance. It takes risk in pips as input which is either fixed or calculated by your trade algorythm, uses risk% which is an external variable and reads account balance. I use it with only 1 trade open at a time, but I see no reason it wouldn't work with multiple trades as it is not based on equity but account balance.
Thanks but i dont think this would work for more than one trades. We would need a loop to cycle through each trade and then add the total risk having gone through the loop.
bluesman:
This Money management routine works.....
Perhaps . . perhaps not. MathMod() can give incorrect results . . . https://www.mql5.com/en/forum/129832
This Money management routine works.....
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I have a function here that i use to calculate the total risk per currency pair.
I have it displayed on my chart so i know my total exposure if all trades on that pair hit there stop loss.
Assume i have a BUY trade open...
This code seems to calculate the correct risk if i have one trade open and stoploss is <= or >= orderopenprice.
This code seems to calculate the correct risk if i have two or more trades open and ALL stoploss's are < orderopenprice.
The code calculates everything wrong if i have more than one trade open and i have at least one trade >= orderopenprice.
Can anyone can fix this code or rewrite how it should be.
I would be very grateful if you can.
Thanks.