code help

 
i need a code for selecting all deposit using Order Select() in the terminal
double p =0.0;
for(int k = OrdersHistoryTotal(); k>=0; k--){
   if(OrderSelect(k,SELECT_BY_POS,MODE_HISTORY){
      if(OrderType() == OP_BUY || OrderType() == OP_SELL) continue;
         if(OrderType() != OP_BUY && OrderType() != OP_SELL)
           {
              p+=OrderProfit();
           }
       }
  return(p);
}
    
MQL5 jobs
MQL5 jobs
  • www.mql5.com
Orders for the development of automated trading programs
 

Try it.

double Deposit() {
 double value =0 ;
 for(int cnt=0;cnt<OrdersHistoryTotal();cnt++)  {
 if(OrderSelect(cnt,SELECT_BY_POS,MODE_HISTORY)) {
     if(OrderType() <= 5 ) continue;
     if( OrderProfit() > 0 ) value += OrderProfit();
    }}
 return (value);
}

 
tuoitrecuoi:

Try it.

double Deposit() {
 double value =0 ;
 for(int cnt=0;cnt<OrdersHistoryTotal();cnt++)  {
 if(OrderSelect(cnt,SELECT_BY_POS,MODE_HISTORY)) {
     if(OrderType() <= 5 ) continue;
     if( OrderProfit() > 0 ) value += OrderProfit();
    }}
 return (value);
}

It gives Zero instead of deposit amount.
 

how you used it ? see comment on left chart.

Files:
 
my trading terminaltuoitrecuoi:

how you used it ? see comment on left chart.

I think the problem remains the fact that some trades history has been removed from the  terminal pool. For accounts with short time of activities, the deposit will be there but when there are too many order history or the account has been opened for long time, the initial deposit will not be seen in the terminal.

How do i work around this? I know that Metaquotes always get this history for calculation of account growth, Maximum DrawDown, Distribution and other Calculations. I think since they can get this from my Trading Account details, there should be a way of getting initial deposit and all other info from my account if it is no longer listed in the trading terminal.  

Reason: