how to get total used lot size

To add comments, please log in or register
Vyckaa
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 :)

Simon Gniadkowski
17213
Simon Gniadkowski  
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.
Vyckaa
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 :/
Simon Gniadkowski
17213
Simon Gniadkowski  
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>

William Roeder
20210
William Roeder  
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(); }
Vyckaa
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
Vyckaa
144
Vyckaa  
WHRoeder 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.
Tran Ngoc Dung
156
Tran Ngoc Dung  

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

Files:
Keith Watford
Moderator
20371
Keith Watford  
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. 

Tran Ngoc Dung
156
Tran Ngoc Dung  
Keith Watford:

Please only attach mq4 source files. 

Sorry, i have edited my post. Thankyou!

Shuhua Shen
1388
Shuhua Shen  
Can it show total used lot size?
To add comments, please log in or register