1. Here is my code that I used in all my EAs to count the total lots of long and short positions ...

Code:
```double TotalOpenLotsUP(string smbl){
int cnt, total;
double lot = 0;
total = OrdersTotal();
for(cnt=0; cnt<total; cnt++){
if(OrderSymbol()==smbl && OrderMagicNumber()==MagicUP)
lot = lot + OrderLots();
}
return(lot);
}

double TotalOpenLotsDN(string smbl){
int cnt, total;
double lot = 0;
total = OrdersTotal();
for(cnt=0; cnt<total; cnt++){
if(OrderSymbol()==smbl && OrderMagicNumber()==MagicDN)
lot = lot + OrderLots();
}
return(lot);
}```

2. ## Function to get the lot count of open orders.

Originally Posted by christion
HI
I wanna count the lots of all open orders (OP_Buy and OP_Sell).
could someone tell me the code to count the lots of all open orders?
The following function will display the lot count for your open buy and sell orders.

Code:
```void lot_count(){
for(int x=OrdersTotal()-1; x>=0; x--){
if(OrderType()==OP_SELL){ sell_lots=sell_lots+OrderLots();}
}
"\nSell lots: ",NormalizeDouble(sell_lots,2),
}```
You're welcome.
- CodeMonkey

3. Originally Posted by oshaban
Here is my code that I used in all my EAs to count the total lots of long and short positions ...

Code:
```double TotalOpenLotsUP(string smbl){
int cnt, total;
double lot = 0;
total = OrdersTotal();
for(cnt=0; cnt<total; cnt++){
if(OrderSymbol()==smbl && Order_Type() == OP_BUY && OrderMagicNumber()==MagicUP)
lot = lot + OrderLots();
}
return(lot);
}

double TotalOpenLotsDN(string smbl){
int cnt, total;
double lot = 0;
total = OrdersTotal();
for(cnt=0; cnt<total; cnt++){
if(OrderSymbol()==smbl && Order_Type() == OP_SELL && OrderMagicNumber()==MagicDN)
lot = lot + OrderLots();
}
return(lot);
}```
You may use same above code in this way ...

double Total_lots = TotalOpenLotsUP(symbol()) + TotalOpenLotsDN(symbol());

Change magic number according to yours ...

That's all !.

4. Hi ...
I don't understand what you mean by the "rest of the lots !" ... would you please clarify that !.

5. if you want to count the number of buy and sell orders but not the lots,
You just need to replace

Lots = Lots + OrderLots();

with

Lots ++;

That's it.

6. Everything is clear ... Please, just concentrate on what I wrote ... You can have all the options you like ...
Profit for up, profit for down, lots for up, lots for down, total profit and total lots.

It is a code, playing with it can give you the result you want.

Good luck ...