# OrderSelect - all EURUSD deals

22

Hi Guys,

Do you have any idea how to check profit for all closed EURUSD positions from current day?

The code below returns only last closed order profit.

```OrderSelect(OrdersHistoryTotal()-1, SELECT_BY_POS,MODE_HISTORY);

Print(OrderProfit());```

I make deals on EURUSD and EURJPY, but need only calculate profit for one instrument (EURUSD).

Moderator
18017

dolar:
Hi Guys,

Do you have any idea how to check profit for all closed EURUSD positions from current day?

The code below returns only last closed order profit.

I make deals on EURUSD and EURJPY, but need only calculate profit for one instrument (EURUSD).

Loop through all the closed positions, OrderSelect() them one by one, check their OrderSymbol() if it matches EURUSD and their OrderOpenTime() is from today keep a running total of OrderProfit(), DONE.
22

something like this?

```for(int i=(OrdersHistoryTotal()-1);i>=0;i--)
{
OrderSelect(i, SELECT_BY_POS,MODE_HISTORY);
if(OrderSymbol()==Symbol() && (TimeToStr(OrderCloseTime(),TIME_DATE))==(TimeToStr(TimeCurrent(),TIME_DATE)))
{

Print(OrderProfit());

break;
}
}```
15019

1. `OrderSelect(i, SELECT_BY_POS,MODE_HISTORY);`
What are Function return values ? How do I use them ? - MQL4 forum
2. `(TimeToStr(OrderCloseTime(),TIME_DATE))==(TimeToStr(TimeCurrent(),TIME_DATE)`
Do you really think you must convert datetimes to strings in order to compare them? Do you really think that the last order will always have the same hour:minute was current time? What if the order closed 12:01:59 and now is 12:02:00?