How to separate balance of each EA virtually?

 
I am now combining 4 EAs into 1 EA (I deal with Each EA as a function) and it seems to work properly,  but I’ve got one problem for position-sizing.

When I use AccountInfoDouble(ACCOUNT_BALANCE),  it returns the total balance of

4.EAs and  each order is calculated based on the balance.

That’s not what I want. I


I want to separate balance of each EA virtually so that I can calculate the position-sizing based on the separated balance of each EA(function).


For example, if I run EA_1 and  EA_2  on the same EA,  I want to have a virtual balance for EA_1 and another virtual balance for EA_2.

.

Each balance must be  independent.


Could anyone help me to solve this problem?


I would appreciate any information you could give me.



Thanks

Documentation on MQL5: Account Information / AccountInfoDouble
Documentation on MQL5: Account Information / AccountInfoDouble
  • www.mql5.com
Account Information / AccountInfoDouble - Reference on algorithmic/automated trading language for MetaTrader 5
 

Hello you can separate them by using: 

ORDER_MAGIC

ID of an Expert Advisor that has placed the order (designed to ensure that each Expert Advisor places its own unique number)

long


See: https://www.mql5.com/en/docs/constants/tradingconstants/orderproperties 

Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Order Properties
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Requests to execute trade operations are formalized as orders. Each order has a variety of properties for reading. Information on them can be obtained using functions Position identifier that is set to an order as soon as it is executed. Each executed order results in a deal that opens or modifies an already existing position. The...
 
mu_world:


When I use AccountInfoDouble(ACCOUNT_BALANCE),  it returns the total balance of

4.EAs and  each order is calculated based on the balance.

Correction Here, It isnt showing total balance of 4 EAs it is showing the account info with respect to the ACCOUNT_BALANCE. even if you remove all 4 EAs the AccountInfoDouble returned values will never be affected. 

in simple terms you are using the wrong function. 

what you want is to either 

1. Divide the Account Balance into Number of EAs, hold each in maybe an array or in a structure.

double EA_Balance[4];
input balance_1 = 0.25,
balance_2=0.25,balance_3 = 0.4; 

//Inside some function 
EA_Balance[0]= balance_1*ACCOUNT_BALANCE
EA_Balance[1]= balance_2*ACCOUNT_BALANCE
//etc 
then have 

#include Trade
CTrade m_trade[4];

//inside Init
m_trade[0].setMagic(EA_1_Magic);
//etc
 
Jefferson Metha:

Correction Here, It isnt showing total balance of 4 EAs it is showing the account info with respect to the ACCOUNT_BALANCE. even if you remove all 4 EAs the AccountInfoDouble returned values will never be affected. 

in simple terms you are using the wrong function. 

what you want is to either 

1. Divide the Account Balance into Number of EAs, hold each in maybe an array or in a structure.

Thank you for the reply.  I understand that I should initially divide  the Account Balance into Numbers of EAs, but after that I really don't know how to hold the separated balance.

Even if I set an array like "EA_Balance[0]= balance_1*ACCOUNT_BALANCE", I don't think that I can hold the EA_Balance[0] independently.  

For example, I need only EA_Balance[0] is effected by EA_1's order and deal.  

 
Marco vd Heijden:

Hello you can separate them by using: 

ORDER_MAGIC

ID of an Expert Advisor that has placed the order (designed to ensure that each Expert Advisor places its own unique number)

long


See: https://www.mql5.com/en/docs/constants/tradingconstants/orderproperties 

Thank you for the reply.

Even if I can separate each EA's order,  I think it doesn't mean that I can hold separated balance individully.

Am I wrong?

 
metamitsu:

Thank you for the reply.  I understand that I should initially divide  the Account Balance into Numbers of EAs, but after that I really don't know how to hold the separated balance.

Even if I set an array like "EA_Balance[0]= balance_1*ACCOUNT_BALANCE", I don't think that I can hold the EA_Balance[0] independently.  

For example, I need only EA_Balance[0] is effected by EA_1's order and deal.  

What? 

EA1 uses MAgicNumber 1  also uses EA_Balance[0] for balance and also you will adjust EA_Balance[0] based on the Profit or Loss that EA1 encounters 

can you please explain this code I sent above here. 

Jefferson Metha:


Though what I sent isnt complete code and has million erors the idea I beleive is clear. 
when you say 

metamitsu:

 hold separated balance individully.

what do you mean 

what is it that you want to do exactly 



link will get you someone thatcan write the code for you and you analyse the code and see where you was going wrong 

Trading applications for MetaTrader 5 to order
Trading applications for MetaTrader 5 to order
  • www.mql5.com
Hello Devs! I would like a simple trailing stop expert, with some scaling out options, which most probably many of you already have built before. Please check the attached zip for info i have An Expert Advisor Source code But the strategy is not working, Its Multisymbol and use Indicators on Three Time Frame i want to add Panel for manual...
 
Jefferson Metha:

What? 

EA1 uses MAgicNumber 1  also uses EA_Balance[0] for balance and also you will adjust EA_Balance[0] based on the Profit or Loss that EA1 encounters 

can you please explain this code I sent above here. 

Though what I sent isnt complete code and has million erors the idea I beleive is clear. 
when you say 

what do you mean 

what is it that you want to do exactly 



link will get you someone thatcan write the code for you and you analyse the code and see where you was going wrong 


Thank you again.  I understand your idea that adjusting EA_Balance[0] based on the Profit or Loss that EA1 encounters,  but how is it possible?

Everytime I send an order, take profit and cut loss, should I call EA_Balance[0] and add or subtract to that?

 
metamitsu:

Thank you for the reply.

Even if I can separate each EA's order,  I think it doesn't mean that I can hold separated balance individully.

Am I wrong?

You can then filter all positions and calculate profit / loss for every EA individually.

What are you trying to do exactly ?