Download MetaTrader 5

order open time sort by opening time

To add comments, please log in or register
bah12ram
76
bah12ram 2016.10.05 18:03 

How can I sort open time of Orders descending or ascending in my code:

Ticket            open price    open time    symbol   
40739542    9844.79    2016.05.18 11:50:27   
48327797    10280.5    2016.10.04 20:43:05    DAX30       
40739556    15.882    2016.05.18 11:50:44    DTEDE   
40739557    15.908    2016.05.18 11:50:44    DTEDE       
48328053    1.12427    2016.10.04 20:46:33    EURUSD   
40739708    125.337    2016.05.18 11:53:21    VOWDE   

void OnStart()
  {
//---
    int handle=FileOpen("OrdersReport.csv",FILE_WRITE|FILE_CSV,"\t");
  if(handle<0) return(0);
  // write header
  FileWrite(handle,"#","open price","open time","symbol");
  int total=OrdersTotal();
  // write open orders
  for(int pos=0;pos<total;pos++)
    {
     if(OrderSelect(pos,SELECT_BY_POS)==false) continue;
     FileWrite(handle,OrderTicket(),OrderOpenPrice(),OrderOpenTime(),OrderSymbol());
    }
  FileClose(handle);

  }

To add comments, please log in or register