See the news Useful hints for the Championship participants
golden188:
Could someone please help me with some language to make my Expert Advisor trade a percentage of my balance? For example, I would like each trade, instead of being x number of lots, to be 10% of my current balance. Does anyone know how to do this? The more explicit the details the more helpful it would be.
thanks.
I use the following function:Could someone please help me with some language to make my Expert Advisor trade a percentage of my balance? For example, I would like each trade, instead of being x number of lots, to be 10% of my current balance. Does anyone know how to do this? The more explicit the details the more helpful it would be.
thanks.
extern double Lots = 0.1; extern double MinLot = 0.1; extern double MaxLot = 5.0; extern int LotPrec = 1; extern bool DynamicLot = false; extern double LotStep = 0.1; extern double BalanceStep = 500; double GetLots() { double lots = Lots; if (DynamicLot) { lots = NormalizeDouble(LotStep*AccountBalance()/BalanceStep, LotPrec); } lots = MathMax(lots, MinLot); lots = MathMin(lots, MaxLot); return (lots); }
this would be another way:
AccountIsMini = true; // Change to False if trading a 100k/regular account
if mm <> 0 then
{
lotMM = Ceil(Balance * risk / 10000) / 10;
if lotMM < 0.1 then lotMM = lots;
if lotMM > 1 then lotMM = Ceil(lotMM);
if AccountIsMini then lotMM = lotMM * 10;
if lotMM > 100 then lotMM = 100;
}
else {
lotMM = Lots; // Change mm to 0 if you want the Lots parameter to be in effect
};
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
thanks.