# Count number of trades per symbol

48

Hello everybody. I would like to see if you can help me with a problem i've been having.

```if(existeOrdenSell() == false)
{
orderSend(...);
}
if(existeOrdenBuy() == false)
{
orderSend(...);
}

bool existeOrdenSell()
{
existeSell = false;
for(int i = 0; i < OrdersTotal(); i++)
{
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if(OrderSymbol() == Symbol())
{
if(OrderType() == OP_SELL || OrderType() == OP_SELLSTOP)
{
existeSell = true;
break;
}
}
}
}
return(existeSell);
}

bool existeOrdenBuy()
{
existeBuy = false;
for(int a = 0; a < OrdersTotal(); a++)
{
if(OrderSelect(a, SELECT_BY_POS, MODE_TRADES))
{
if(OrderSymbol() == Symbol())
{
if(OrderType() == OP_BUY || OrderType() == OP_BUYSTOP)
{
existeBuy = true;
break;
}
}
}
}
return(existeBuy);
}```

I have this piece of code so that the EA only executes 1 buy and 1 sell per symbol.

Now, what i need to do is the EA trade when pairs are done. What I mean with a pair is 1 buy and 1 sell executed. When these two orders are executed allow another pair.

I will try to resume the process so it is clear:

1) BuyStop order is open.

2) Only can be open a SellStop...It is open now

3) The EA now allow more trade (the same, 1 buy and 1 sell only).

4) SellStop order is open.

5) Only can be open a BuyStop... It is open now

6) The EA now allow more trade (the same, 1 buy and 1 sell).

7) And so on...

That is why i thought that an algorithm that count the number of trades per symbol, or maybe one that count the number of buys and sells per symbol, so that i know when it should allow the next pair.

So, what do you think? Can you help me??

5299

What I do is count the number of buy_orders and the number of sell_orders.

If the number of buy_order>sell_orders then return() or dont-place-buy_orders.

Vice-versa for sell logic.

6636

Make use of an OrdermagicNumber()

And Check trades counting down loop

And counting all your different OrderType() can be done in one loop it is not needed to do it twice

33

Ubzen:

What I do is count the number of buy_orders and the number of sell_orders.

If the number of buy_order>sell_orders then return() or dont-place-buy_orders.

Vice-versa for sell logic.

Hi Ubzen,
Were you able to find a solution to this, I too don't mind having over 10 trades open at the same time, just as long as they are of different pairs or assets that the EA is attached to.

Thanks in advance.
33

Andres Perez:

Hello everybody. I would like to see if you can help me with a problem i've been having.

I have this piece of code so that the EA only executes 1 buy and 1 sell per symbol.

Now, what i need to do is the EA trade when pairs are done. What I mean with a pair is 1 buy and 1 sell executed. When these two orders are executed allow another pair.

I will try to resume the process so it is clear:

1) BuyStop order is open.

2) Only can be open a SellStop...It is open now

3) The EA now allow more trade (the same, 1 buy and 1 sell only).

4) SellStop order is open.

5) Only can be open a BuyStop... It is open now

6) The EA now allow more trade (the same, 1 buy and 1 sell).

7) And so on...

That is why i thought that an algorithm that count the number of trades per symbol, or maybe one that count the number of buys and sells per symbol, so that i know when it should allow the next pair.

So, what do you think? Can you help me??

Hi Andrez,
Were you able to find a solution to this, I too don't mind having over 10 trades open at the same time, just as long as they are of different pairs or assets that the EA is attached to.

Thanks in advance.
To add comments, please log in or register