Order Sellect Issue

 

Hi,

Can anyone help me with the following;

I've created a function to search and find the oldest open trade and the output is the ticket number, it works fine....but

int FindOlderTrade() {

int older_time;

int ticket;

for (int tomate = OrdersTotal() - 1; tomate >= 0; tomate--) {

OrderSelect(tomate, SELECT_BY_POS, MODE_TRADES);

if (OrderSymbol() != Symbol() || OrderMagicNumber() != MN1) continue;

if (TimeCurrent()-OrderOpenTime() > older_time) {

older_time = TimeCurrent()-OrderOpenTime();

ticket = OrderTicket();

}

}

return (ticket);

}

........... when a try to do the same to search and find the the oldest trade size with a similar function it does not work, returns 0 :

int FindOlderTradeSize() {

int older_time;

double lt;

for (int tomate = OrdersTotal() - 1; tomate >= 0; tomate--) {

OrderSelect(tomate, SELECT_BY_POS, MODE_TRADES);

if (OrderSymbol() != Symbol() || OrderMagicNumber() != MN1) continue;

if (TimeCurrent()-OrderOpenTime() > older_time) {

older_time = TimeCurrent()-OrderOpenTime();

lt = OrderLots();

}

}

return (lt);

}

Any help would be much appreciated..

Thank you

 

Use SRC button to display your code

You want your function return the size of It (oldest OrderLots() )

int FindOlderTradeSize() // ??

is that correct definition ??

 

Thank you deVries,

I changed "int" by "double" and worked fine .......

Reason: