How to get OrdersHistoryTotal() to return only closed orders for today ?

 

I guess I should be asking if I can actually get OrdersHistoryTotal() and limit the return to show the closed trades for today only ? 

I mean I know I can Print(OrdersHistoryTotal()); and this will give me the total orders of whatever I select in the tab of the account history. 
If I select Account History and change the dates to custom/today then I get the OrderHistoryTotals for today. 

However, what to do if I don't change the Account History to show only one day then how would I go about finding this out. 

Please advise, thanks







 

 
Agent86:

I guess I should be asking if I can actually get OrdersHistoryTotal() and limit the return to show the closed trades for today only ? 

I mean I know I can Print(OrdersHistoryTotal()); and this will give me the total orders of whatever I select in the tab of the account history. 
If I select Account History and change the dates to custom/today then I get the OrderHistoryTotals for today. 

However, what to do if I don't change the Account History to show only one day then how would I go about finding this out. 

Please advise, thanks







 

void SELECT_TRANSACTIONS_CLOSED_TODAY_ONLY()
 {
    for(int i=OrdersHistoryTotal()-1;i>=0;i--)
     {
        if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true)
           if(TimeDay(OrderCloseTime())==Day()&&OrderSymbol()==Symbol())
              //......here goes your code what to do about those orders...example...
              Print(OrderProfit()+OrderTicket());
     }
 }


this function would find orders that you want to process:)Cheers:)

  if ( TimeDay ( OrderCloseTime () ) == Day () )

it is important:)

Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
  • www.mql5.com
//| Expert initialization function                                   | //| Expert deinitialization function                                 | //| Expert tick function                                             | //| test1                                                            |...
 
Piotr Latoszynski:

void SELECT_TRANSACTIONS_CLOSED_TODAY_ONLY()
 {
    for(int i=OrdersHistoryTotal()-1;i>=0;i--)
     {
        if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true)
           if(TimeDay(OrderCloseTime())==Day()&&OrderSymbol()==Symbol())
              //......here goes your code what to do about those orders...example...
              Print(OrderProfit()+OrderTicket());
     }
 }


this function would find orders that you want to process:)Cheers:)

  if ( TimeDay ( OrderCloseTime () ) == Day () )

it is important:)

I see, thanks. 
I'll play with this some tomorrow and check returns to see what it's telling me. 

Thanks.