# Thread: Verification for OpenOrders and do .....?

1. ## Verification for OpenOrders and do .....?

Hello!
I need just a little help..
I have a problem in the code..
Example:
Check for OpenOrders and if there is 1 open order, the next open order will be 1 lot. If there is 2 Opened orders the next one will be whit 2 lots..: I have Buy signal,the expert chek for OpenOrders and found 1 Order=> the order that will be open will be whit 1lot.....
Something like this. But becaouse I don't know the correctly code for Order counting i need help ...

Good luck!

P.S Sorry for my bad EN.

2. Originally Posted by begin_er
Hello!
I need just a little help..
I have a problem in the code..
Example:
Check for OpenOrders and if there is 1 open order, the next open order will be 1 lot. If there is 2 Opened orders the next one will be whit 2 lots..: I have Buy signal,the expert chek for OpenOrders and found 1 Order=> the order that will be open will be whit 1lot.....
Something like this. But becaouse I don't know the correctly code for Order counting i need help ...

Good luck!

P.S Sorry for my bad EN.
Hi begin_er and welcome,

You have to add a count orders function :

Code:
```//|---------count orders

int CountOrders(int Type,int Magic)
{
int _CountOrd;
_CountOrd=0;
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSymbol()==Symbol())
{
if((OrderType()==Type&&(OrderMagicNumber()==Magic)||Magic==0))_CountOrd++;
}
}
return(_CountOrd);
}```
Then in your OrderSend functions, replace Lots by :

Code:
```NormalizeDouble(Lots*CountOrders(OP_BUY,Magic),2)
NormalizeDouble(Lots*CountOrders(OP_SELL,Magic),2)```

3. Thank you, thank you verry much!! funyoo You are good man
Verry quickly post, but now i don't have time to write the code. When I finish, i will post. THANK!!!

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•