Download MetaTrader 5

how many chart has the same expert run on it ? ( is there a function )

To add comments, please log in or register
Mehrdad Shiri
4535
Mehrdad Shiri  

hi;

is there a function to identify : from several  chart is availabe on metatrader , how many of them have the same expert run on them. ?

or how can do this ?

use these case for calculating and used in money management.

Alain Verleyen
Moderator
31476
Alain Verleyen  
TIMisthebest:

hi;

is there a function to identify : from several  chart is availabe on metatrader , how many of them have the same expert run on them. ?

or how can do this ?

use these case for calculating and used in money management.

I guess it's your own EA ? So you can, for example, use a global variable to "register" each instance of your EA.
Mehrdad Shiri
4535
Mehrdad Shiri  
angevoyageur:
I guess it's your own EA ? So you can, for example, use a global variable to "register" each instance of your EA.

yes.

thank to reply;

and then ; sum of them return and can see on all those chart we have the same equal number ?

how to count and sum ? ( sorry , i dont understand it )

1.) do you mean by : " GlobalVariablesTotal ()" and then by divide it on the number of global value we have in our expert ?

2.) if there was another ea send global vaue ?

Benjamin Dixon
23532
Benjamin Dixon  
TIMisthebest:

yes.

thank to reply;

and then ; sum of them return and can see on all those chart we have the same equal number ?

how to count and sum ? ( sorry , i dont understand it )

1.) do you mean by : " GlobalVariablesTotal ()" and then by divide it on the number of global value we have in our expert ?

2.) if there was another ea send global vaue ?

simplest way is to use a single gv as a counter. your ea can add 1 in oninit and subtract 1 in ondeinit. if any ea crashes or somehow turns off or reinitialized without deinitializing though the count would be incorrect until you manually fix it... to circumvent that it seems like it will be a bit of work, I think you may have to use timestamps in individual gv's. 

 Why do the ea need to know this? 

Benjamin Dixon
23532
Benjamin Dixon  

It might even be better to create a single ea that trades on multiple timeframes and currencies instead of trying to communicate between instances of the same ea:

https://www.mql5.com/en/articles/105

Creating an Expert Advisor, which Trades on a Number of Instruments
Creating an Expert Advisor, which Trades on a Number of Instruments
  • 2010.07.08
  • Nikolay Kositsin
  • www.mql5.com
The concept of diversification of assets on financial markets is quiet old, and has always attracted beginner traders. In this article, the author proposes a maximally simple approach to a construction of a multi-currency Expert Advisor, for an initial introduction to this direction of trading strategies.
Mehrdad Shiri
4535
Mehrdad Shiri  
bendex77:

simplest way is to use a single gv as a counter. your ea can add 1 in oninit and subtract 1 in ondeinit. if any ea crashes or somehow turns off or reinitialized without deinitializing though the count would be incorrect until you manually fix it... to circumvent that it seems like it will be a bit of work, I think you may have to use timestamps in individual gv's. 

 Why do the ea need to know this? 

hi & thank you.

because of money management.

assume i want to have sum of volume ( lat ) for all my positions limited to 1 lot for every 10000$ balance,.

then ea divided the lot for each chart and send order such that total vol will be as we want i .

and if number of chart who has this expert , changed ; it can automatically redistribution .

To add comments, please log in or register