Problem with 1 EA for several currency pairs

 

Hi,
I am running a same EA on different currency pairs. I want only 4 trade opened for any specific currency pair, meanwhile maximum total trade for all currency pairs is 30 trades. For e.g I would need 4 trades opened for EURUSD, other opened trades can be of different currency pair but not EURUSD, until total trades of all currency pairs reaches 30 trades. Can any body help me with that ???

 
bellar:

Hi,
I am running a same EA on different currency pairs. I want only 4 trade opened for any specific currency pair, meanwhile maximum total trade for all currency pairs is 30 trades. For e.g I would need 4 trades opened for EURUSD, other opened trades can be of different currency pair but not EURUSD, until total trades of all currency pairs reaches 30 trades. Can any body help me with that ???


Here for example.
 

 Dear angevoyageur,

Thx for the example.

For my special purpose (Total 30, subtotal 4), I tried to use the example as belows : 

 

.............
symbol=Symbol();
total=OrdersTotal();
my_total=0;
for(i=0; i<total; i++)
{
 OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
 if(OrderSymbol()==symbol) my_total++;
 }
if((total<30)&&(my_total<4))
{
.............



Would you like to give your suggestion whether it is right or not ? 

 

Please edit your post and use SRC button when you post code.

Your code is not logically right. OrdersTotal() may include pending orders, manual orders and other EA orders. So you have to count orders of your EA, you can use MagicNumber for that.