Topic: How to Add a Simple Money Management for Portfolio EA in 2 Easy Steps
Dear EA Studio Users,
I'd like to share an easy method to add a simple money management to your portfolio expert. I'm not a mql expert, I just want to share something I know and personally use.
By applying this money managament the EA will increase the lot size by 0.01 lot per 1000 balance.
You need to open your mq4 files via metaeditor first.
Okay, here are the steps
1. Replace this code
static input double Entry_Amount = 0.01; // Entry lots
with this
extern bool Auto_Lot=1;
extern double Risk_Multiplier=1;
static input double Entry_Amount = 0.01; // Entry lots
2. Replace this code
double stopLoss = signal.StopLossPips>0 ? GetStopLoss(command, signal.StopLossPips) : 0;
double takeProfit = signal.TakeProfitPips>0 ? GetTakeProfit(command, signal.TakeProfitPips) : 0;
string comment = IntegerToString(signal.MagicNumber);
color arrowColor = command==OP_BUY ? clrGreen : clrRed;
with this
if(!Auto_Lot){amount=Entry_Amount;}else
if(Auto_Lot){
amount=((AccountBalance()*Risk_Multiplier)/100)/1000;
}
double stopLoss = signal.StopLossPips>0 ? GetStopLoss(command, signal.StopLossPips) : 0;
double takeProfit = signal.TakeProfitPips>0 ? GetTakeProfit(command, signal.TakeProfitPips) : 0;
string comment = IntegerToString(signal.MagicNumber);
color arrowColor = command==OP_BUY ? clrGreen : clrRed;
if(amount<=MarketInfo(_Symbol,MODE_MINLOT)){amount=MarketInfo(_Symbol,MODE_MINLOT);Comment("______ Use MIN LOT ______");}else
if(amount>=MarketInfo(_Symbol,MODE_MAXLOT)){amount=MarketInfo(_Symbol,MODE_MAXLOT);Comment("______ Use MAX LOT ______");}else
Comment("");
Done, now you can compile and backtest your EA to see if it works. Risk_Multiplier=1 means 0.01 lot per 1000, Risk_Multiplier=2 means 0.02 lot per 1000, and so on.
I hope you'll find it useful.
Best regards.