Download MetaTrader 5

code help

To add comments, please log in or register
gbenga Ayodele
249
gbenga Ayodele  
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
Trinh Dat
38375
Trinh Dat  

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);
}

gbenga Ayodele
249
gbenga Ayodele  
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.
Trinh Dat
38375
Trinh Dat  

how you used it ? see comment on left chart.

Files:
gbenga Ayodele
249
gbenga Ayodele  
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.  

To add comments, please log in or register