How to select date range from MODE_HISTORY

To add comments, please log in or register
Bret Sallee
113
Bret Sallee  

Hello,


Is it possible to define the amount of account history that the MODE_HISTORY extracts from MT4.  I'm trying to limit the date range of the output for this indicator.

Thanks in advance.

<ex4 file deleted>

//+--------------------------------------------------------------------------+
  double GetProfitFromDateInCurrency(string sy="", int op=-1, int mn=-1, datetime dt=0)
  {
  double p=0;
  int    i, k=OrdersHistoryTotal();
  if     (sy=="0") sy=Symbol();
  for    (i=0; i<k; i++) {
  if     (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {
  if     ((OrderSymbol()==sy || sy=="") && (op<0 || OrderType()==op)) {
  if     (OrderType()==OP_BUY || OrderType()==OP_SELL) {
  if     (mn<0 || OrderMagicNumber()==mn) {
  if     (dt<OrderCloseTime()) {
         p+=OrderProfit()+OrderCommission()+OrderSwap();
  } } } } } }
  return (p);
  }
William Roeder
18347
William Roeder  
  1. Why did you post your MT4 question in the Root / MT5 General section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. When you post code please use the CODE button (Alt-S)! (For large amounts of code, attach it.) Please edit your (original) post.
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  3. "0" and "" are not the same.

  4. Bret Sallee: I'm trying to limit the date range of the output for this indicator.
    Exactly what your code does.

  5. Don't post compiled code, we can't read it.
Bret Sallee
113
Bret Sallee  
The indicator draws from the Account History.  It takes all the trades located there.  When I modify the date range within Account History it only stays for a short period of time and then reverts to "All History" so was hoping there was a way to stipulate a date range within the code when it calls for the history.
To add comments, please log in or register