OrderSelect() question.

 

Hello MQL4 community,

I am trying to add order profit values of partial order closes.

Example:

0.04 lots Order is opened,

0.01 lots closes, (I wish to save the order close profit)

0.01 lots closes, (I wish to save the order close profit)

etc. until 0.04 lots is closed.


I have been trying to use OrderSelect() function, but to no avail.

Example:

OrderSelect(i-1,SELECT_BY_TICKET,MODE_TRADES); // selects the last closed partial order close profit (does not select the most recent closed partial order profit).

OrderSelect(i,SELECT_BY_TICKET,MODE_TRADES);   // selects the current open partial order profit.

// neither one selects the order close profit of the most recent (not the last, but the most recent).

I wish to select the most recent closed partial order profit so that I can save each value and add them to see if all added partial netted orders close in profit or loss. Neither of the above functions work, any thoughts or ideas would be appreciated.

Thank you.

 
WhooDoo22:

Hello MQL4 community,

I am trying to add order profit values of partial order closes.

Example:

0.04 lots Order is opened,

0.01 lots closes, (I wish to save the order close profit)

0.01 lots closes, (I wish to save the order close profit)

etc. until 0.04 lots is closed.


I have been trying to use OrderSelect() function, but to no avail.

Example:

I wish to select the most recent closed partial order profit so that I can save each value and add them to see if all added partial netted orders close in profit or loss. Neither of the above functions work, any thoughts or ideas would be appreciated.

Thank you.

The OrderSelect () function is boolean therefore you need to test whether it finds the order..

if(OrderSelect(Order#, SELECT_BY_TICKET)==true)
....
...do something here with the order

 If the order is in Account History the OrderCloseTime() will NOT equal zero.

 

sd59,

Thanks much. I'll give it a shot.

Reason: