# Thread: Best ways to manage multiple EA's over total investment?

1. ## Best ways to manage multiple EA's over total investment?

Perhaps a simple question, but i guess there are many ways to accomplish this, and i am wondering what methods there are for the following example:

Suppose we have collected 20 different profitable EA's and we have an investment of 36000 Dollar.
Suppose we want to divide this investment as follows:

5 EA's should each have 3000 Dollar to work with.
6 EA's should each have 2000 Dollar to work with.
9 EA's should each have 1000 Dollar to work with.

We want to be flexible with the amount that we allow each EA to work with, and each EA should never use more.

How can we accomplish this? Maybe certain additional software?

Perhaps a simple question, but i guess there are many ways to accomplish this, and i am wondering what methods there are for the following example:

Suppose we have collected 20 different profitable EA's and we have an investment of 36000 Dollar.
Suppose we want to divide this investment as follows:

5 EA's should each have 3000 Dollar to work with.
6 EA's should each have 2000 Dollar to work with.
9 EA's should each have 1000 Dollar to work with.

We want to be flexible with the amount that we allow each EA to work with, and each EA should never use more.

How can we accomplish this? Maybe certain additional software?

You have to adapt the money management function in each EA to the wanted capital. For example in my function :

Code:
```double lotsoptimized(){
double lot;
if(stoploss>0)lot=AccountBalance()*(risk/100)/(stoploss*pt/MarketInfo(Symbol(),MODE_TICKSIZE)*MarketInfo(Symbol(),MODE_TICKVALUE));
else lot=NormalizeDouble((AccountBalance()/lotsize)*minlot*risk,lotdigits);
return(lot);
}```
Code:
`AccountBalance()`
Should be replaced by :

Code:
`balance`
And this line should be added in the extern parameters :

Code:
`extern double balance=3000;`

3. Many thanks Funyoo,

I will test it.

4. Hi

Anybady knows how to calculate balance and equitity for each EA indyvidualy. I would like to size the position based on individual equitity calcualation for each EA runing them symulanusly on thesame account.

5. Originally Posted by Misiek80
Hi

Anybady knows how to calculate balance and equitity for each EA indyvidualy. I would like to size the position based on individual equitity calcualation for each EA runing them symulanusly on thesame account.

Hi Misiek80,

You can define a first balance in Init that you use to calculate the risk management.

Code:
`GlobalVariableSet("InitialBalance",AccountBalance());`
Then you calculate the closed profits in Start for the current magic number, you add it to the first balance and you get the last balance.

Code:
```closeprofits=0;

if(OrdersHistoryTotal()>0){
for(i=0;i<=OrdersHistoryTotal();i++){
OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic){
closeprofits=closeprofits+OrderProfit();
}
}
}```
Code:
`GlobalVariableSet("Balance",GlobalVariableGet("InitialBalance")+closedprofits);`
And the current profits to get the equity.

Code:
```openprofits=0;

if(OrdersTotal()>0){
for(i=0;i<=OrdersTotal();i++){
if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderCloseTime()==0){
openprofits=openprofits+OrderProfit();
}
}
}```
Code:
`GlobalVariableSet("Equity",GlobalVariableGet("Balance")+openprofits);`
Code:
```initialbalance=GlobalVariableGet("InitialBalance");
balance=GlobalVariableGet("Balance");
equity=GlobalVariableGet("Equity");```

6. Thanks Funyoo,

It's working.

7. Here try this, this should help A LOT.

8. Hi

Thanks bigpipn.
I have got one more question. Has anybody got indicator that could draw leverage used during trading. Currently I'm using attached indicator for account overview. Would it be possible to add that function to the script. I'm also having issues with missing historic data (usualy when demo account disconets), than the indicator crashes.

9. Hi Funyoo,

As a follow-up to my above question, i suppose this is almost the same:

I run Attached EA on M5 EU on two charts, one chart for longs and the other for shorts.

For instance, the startbalance of 10K can fall to 7K easily, but it is also capable of going back from 7K to 13K relatively fast, i've seen such happen regularly.

Now, to ensure that every profit above the startbalance of 10K is safe, i could take out all profit everytime it comes above 10K, so in my example i could take 3K out of the account, and repeat this when it comes again above 10K.

But in stead of every time taking out the profit, i would like to know if it is possible for you to change the EA's code in a way that it is not needed to actually take out the profit everytime above 10K, but instead the EA would keep the build-up profit in the account, no matter if it blows?