How do i get Deposits and/or Profits

 
Hi! so I've read some posts that make something like this
for (int i= 0; i < OrdersHistoryTotal(); i++) {
   if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY) && OrderType() == 6) {
      deposits += OrderProfit();
   }
}
Improperly formatted code edited by moderator.

But for my case, history only retrieves last month history, not all

Is there a way to just return deposits or profits for the account?

Like how does myfxbook show all the statistics, I know they have all the orders history, but how do I get that?

Thanks in advance.

 
Your topic has been moved to the section: MQL4 and MetaTrader 4
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 
Daniel Alarcon:
Improperly formatted code edited by moderator.

Please always use the CODE button (Alt-S) when inserting code.

Code button in editor

 
Daniel Alarcon: But for my case, history only retrieves last month history, not all

extend your trade history by right-clicking in the "Account History" section and selecting "All History"

 
Fernando Carreiro #:

extend your trade history by right-clicking in the "Account History" section and selecting "All History"

thanks! but I need that in EA, is there a way to get profits / deposits / or all history?


This is Myfxbook, how do they do that?


 
Daniel Alarcon #thanks! but I need that in EA, is there a way to get profits / deposits / or all history? This is Myfxbook, how do they do that?

OrdersHistoryTotal

Returns the number of closed orders in the account history loaded into the terminal.

int  OrdersHistoryTotal();

Returned value

The number of closed orders in the account history loaded into the terminal. The history list size depends on the current settings of the "Account history" tab of the terminal.

---------------------------------------------------

Just do what Fernando said.

 
Miguel Angel Vico Alba #:

OrdersHistoryTotal

Returns the number of closed orders in the account history loaded into the terminal.

Returned value

The number of closed orders in the account history loaded into the terminal. The history list size depends on the current settings of the "Account history" tab of the terminal.

---------------------------------------------------

Just do what Fernando said.

I know but this will be an EA, this needs to be done by EA, i can't access all the pcs in which the EA will be

 
Daniel Alarcon #I know but this will be an EA, this needs to be done by EA, i can't access all the pcs in which the EA will be

No way to get programmatically history trades with specified time period.

This is possible in MT5, where you can define start and end date, but in MT4 you have only access to part of history showing in MT4 account history tab.

Myfxbook does this because you provide you with access as an investor and select to see the entire history. In other words, the only thing you can do is to warn users about this detail.

Do you understand now why MQL5 is so much better and MQL4 is obsolete? 😅

 
Miguel Angel Vico Alba #:

No way to get programmatically history trades with specified time period.

This is possible in MT5, where you can define start and end date, but in MT4 you have only access to part of history showing in MT4 account history tab.

Myfxbook does this because you provide you with access as an investor and select to see the entire history. In other words, the only thing you can do is to warn users about this detail.

Do you understand now why MQL5 is so much better and MQL4 is obsolete? 😅

Thank you so much, should i change the EA to MT5? lol

 
Daniel Alarcon #Thank you so much, should i change the EA to MT5? lol

Absolutely yes. I abandoned MQL4 years ago and once you work with MQL5 you will never want to go back to MQL4.

 
Miguel Angel Vico Alba #:

Absolutely yes. I abandoned MQL4 years ago and once you work with MQL5 you will never want to go back to MQL4.

will do it, thank you very much!

Reason: