# how to get total used lot size

144
Vyckaa

Hello, i wrote my EA. now to finish it i need just to count how many lots is used total from active orders. So maybe you have ideas what function should i use to get the total lots used at the moment from active orders.

for exmp.

order nr:

1.0.01

2.0.02

3.0.03

4.0.05

so i need a sum of all theese, i need to get 0.11)

exmpl;

double usedlots = ???(help) ;

if(usedlots == 0.11)

then = dothat;

else

nothing;

Thank you, i hope you understand :)

17213

Loop through the open orders, OrderSelect() one by one, check Symbol() and Magic Number if applicable, keep a running total of OrderLots() for the orders that match Symbol & Magic Number. Done.
144
Vyckaa
If there are no way to "select all" function at orderselect() becouse, every time is unique and the number of order will not be the same, my ea working with the 10-30 orders in a day, so i have to count the lot size every new bar. If i should use orders numbers i would need to edit my ea everytime :/
17213

Vyckaa:
If there are no way to "select all" function at orderselect() becouse, every time is unique and the number of order will not be the same, my ea working with the 10-30 orders in a day, so i have to count the lot size every new bar. If i should use orders numbers i would need to edit my ea everytime :/

Maybe you can get someone to code it for you . . . I won't.

I'll try to help once more . . .

<pseudo code start>

Loop through the open orders by position. Read here and here

If an order matched the Symbol you want and the Magic Number you want

add iit's OrderLots() to a running total

When the loop is complete your running total is the total number of lots in all your open Orders.

<pseudo code end>

20210

```double totalOpenLots = 0;
for(int iPos = OrdersTotal()-1; iPos >= 0 ; iPos--) if (
OrderSelect(iPos, SELECT_BY_POS)                    // Only my orders w/
&&  OrderMagicNumber()  == Magic.Number                 // my magic number
&&  OrderSymbol()       == chart.symbol                 // and my pair.
){  totalOpenLots += OrderLots(); }
```
144
Vyckaa
Thank you guys both. That was very usefull info :) WHRoeder i will try to integrate your code into my ea and see what happens
144
Vyckaa
it worked ! thank you . The problem is that i not very expieried at mq4 yet, i dont know how to use "for" so thats might be the problem i didnt figure it out how to code, but with your help i am starting to understand.
156

i have a litle code (EA) for calc total lotsize, I hope it helps

Files:
Moderator
20371

Tran Ngoc Dung:

i have a litle code (EA) for calc total lotsize, I hope it helps

<ex4 file removed>

Please only attach mq4 source files.

156

Keith Watford:

Please only attach mq4 source files.

Sorry, i have edited my post. Thankyou!

1388

Can it show total used lot size?