Download MetaTrader 5

Initial Deposit

To add comments, please log in or register
Launch agents on an idle PC. It is profitable!
thalassi
178
thalassi 2011.06.22 09:42 

Is there a way to access the initial deposit in my EA?

forexCoder
507
forexCoder 2011.06.22 11:34  
Ugh I'll be interested to know as well.
Simon Gniadkowski
Moderator
18001
Simon Gniadkowski 2011.06.22 11:52  

A suggestion . . not sure if will work, but it might.

Check your order history and check the comments for "Deposit"

forexCoder
507
forexCoder 2011.06.22 12:01  

Roflmao!!!!!

I guess I should have done my homework myself.

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
   for(int i = OrdersHistoryTotal()-1; i >= 0; i--){
      OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
      Print(OrderTicket(), OrderComment(), OrderMagicNumber());
   }
   

   return(0);
  }
//+----
Quick script for testing all history, and indeed the first one is the Deposit.
zzuegg
1505
zzuegg 2011.06.22 12:48  

Some strategies require the comment field for something else, more general solution is:

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
   double deposit=AccountBalance();
   for(int i = OrdersHistoryTotal()-1; i >= 0; i--){
      OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
      deposit+= (OrderProfit()+OrderSwap()+OrderCommission());
   }
   
   Print(deposit);

   return(0);
  }
//+----

At least this should work.

Simon Gniadkowski
Moderator
18001
Simon Gniadkowski 2011.06.22 13:00  
zzuegg:

Some strategies require the comment field for something else, more general solution is:

At least this should work.

It may work as long as the Account History is set to show All History . . if you check the comment field as well and it is set to "Deposit" then you have confirmation.
zzuegg
1505
zzuegg 2011.06.22 13:06  

Some brokers do modify the comment after an order has closed, some to even change the comment set by you or your ea.

One of my systems needs the comment field from open trades to be able to recovery from a failure.

Theoretically there should also be another OrderType() which handles transfers of funds. I can check that when i am at home.

Simon Gniadkowski
Moderator
18001
Simon Gniadkowski 2011.06.22 13:21  
zzuegg:

Some brokers do modify the comment after an order has closed, some to even change the comment set by you or your ea.

One of my systems needs the comment field from open trades to be able to recovery from a failure.

Theoretically there should also be another OrderType() which handles transfers of funds. I can check that when i am at home.

OrderType = 6 . . Balance, from the looks of it.
whroeder1
14544
whroeder1 2011.06.22 16:04  
    static datetime lastClose;  datetime lastClosePrev = lastClose;
    for(int pos=0; pos < OrdersHistoryTotal(); pos++) if (
        OrderSelect(pos, SELECT_BY_POS, MODE_HISTORY)   // Only orders w/
    &&  OrderCloseTime()    > lastClosePrev             // not yet processed,
    &&  OrderMagicNumber()  == magic.number             // my magic number
    &&  OrderSymbol()       == Symbol()                 // and my pair.
    &&  OrderType()         <= OP_SELL){    // Avoid cr/bal https://www.mql5.com/en/forum/126192
https://www.mql5.com/en/forum/126192
fridaystreet
14
fridaystreet 2011.10.14 10:59  

here https://forum.mql4.com/30708 in the forum it mentions that there are undocumented order types of 6 and 7 (balance and credits). Balance order types refer to withdrawals and deposits. I use the following simple function in my EAs to return the current deposited amount in the account minus withdrawals (ie withdrawals are subtracted automatically through the fact they are negative numbers)

Apparently credits are brokers added funds, you could add this to the function with if(OrderType() == 6 || OrderType() == 7) instead.

double getDeposit(){

int total, cnt;
double deposits;

deposits = 0;
total=OrdersHistoryTotal();

for(cnt=0;cnt<total;cnt++){

OrderSelect(cnt, SELECT_BY_POS, MODE_HISTORY);

if(OrderType() == 6){

deposits+ = OrderProfit();


}

}

return(deposits);

}


Cheers

Paul

Ian Venner
2584
Ian Venner 2011.10.15 00:12  
zzuegg:

Some brokers do modify the comment after an order has closed, some to even change the comment set by you or your ea.

One of my systems needs the comment field from open trades to be able to recovery from a failure.

Theoretically there should also be another OrderType() which handles transfers of funds. I can check that when i am at home.


I use the comment field as part of my failure recovery too I am beginning to wonder if maybe thats not such a good idea as I keep hearing how brokers change the comment i might go back to my original idea which was to use the magic number field.
12
To add comments, please log in or register