extern int RiskFactor = 2.0; //Percent
extern double Lots = 0.1; //Manual Lots if Risk Factor=0
double lot_size() {
double lots;
double LotSize = MarketInfo(Symbol(), MODE_LOTSIZE);
double MinLot = MarketInfo(Symbol(), MODE_MINLOT);
double LotStep = MarketInfo(Symbol(), MODE_LOTSTEP);
if (RiskFactor==0) return (Lots);
lots = (AccountFreeMargin()* AccountLeverage() / LotSize) * RiskFactor/100.0;
if (lots < MinLot) lots = MinLot;
lots /= LotStep;
lots = NormalizeDouble(lots, 0);
lots *= LotStep;
return(lots);
}
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Hi!
I look for code on money and lots managment for expert advisor.
and how to implement them to my expert advisor?
Thanks.
Best regards.
Boogie.