1. ## Count Lots OP_SELL and OP_BUY

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?

thanks!!

chris

2. i wanna count this lots (>> pic)

3. This is Funyoo's code
mode 0 for pips, mode 1 for dollars

Code:
```double countprofit(int mode,string comment,string symbol){
double p=0;
if(OrdersTotal()>0){
for(i=OrdersTotal()-1;i>=0;i--){
if(OrderSymbol()==symbol && OrderComment()==comment || comment=="" && OrderMagicNumber()==magic){
if(mode==1 && OrderType()==type)p+=OrderProfit();
if(mode==0 && OrderType()==OP_SELL && type==OP_SELL){p+=(OrderOpenPrice()-OrderClosePrice())/pt;}
}
}
return(p);
}
}```

4. thank you... but that is counting the profits, isnt it??

how can i count the Lot-sizes of the open buy/sell posistions?

Once you select the order:

OrderType()==OP_SELL ){SellLots = OrderLots();}

Depending on what you want to achieve

if you want to add them up.. {p+=(OrderLots();}

If you want to select the first order

if you want to select the last order

example of selecting the smallest lots open
Code:
```//+-------------------------------------------------------------------------------+ Smallest LOTS +--------------------+
double SmallestLots(string pair){
double orderlots=100;
if(OrdersTotal()>0){
for(i=OrdersTotal()-1;i>=0;i--){
if (OrderLots() <= orderlots)orderlots=OrderLots();
}
if(OrderSymbol()==pair && OrderType()==OP_SELL && OrderMagicNumber()==MagicNumber){
if (OrderLots() <= orderlots)orderlots=OrderLots();
}
}
return(orderlots);```

I hope it makes sense.

6. hi arbus

I've insert this code for the lots >

if(OrdersTotal()>0)
{
openbuylots = 0; openselllots = 0; // set the variables to zero
for(i=0;i<OrdersTotal();i++)
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderCloseTime()==0)
{

if(OrderType()==OP_SELL) openselllots += OrderLots();
}
}
}

7. but after the basketclose there getting something wrong... > pics...

8. and the EA is actually a EA from Funnyo >> the "Dual_Grid_EA" i just wanna change the steps and the lots of the posistions.... here is the one I'm working with....

9. You are probably better to know or find the 1st lot position.
Then just multiply the 1st position to get the rest of the lot sizes you need.

This is Funyoo's original code.
Code:
```if(addpositions){
slots=lots*MathPow(multiplier,count(OP_SELL));
}```
It should work to change the lots of the positions.
It multiplies the number of buy(or sell) orders by the multiplier by the original lots.

To change the steps you need to change "pips" variable.

I am thinking you want to do something else? Do you want to change the step with regard to the number of open orders?

10. hi arbus

yes that works to change the lots, but the problem is, if there are view posistions the lots are big, but if it is breakout in one direktion the OP_Buy or OP_sell are then just only on and the lots of the new posistion is getting to small.

the steps are fine/ok.

i only wanna count the open lots
>>> blots=lots+(openselllots*multiplier)

and thank you for your help!!!