how to calculate total amount deposited to the account?
You need to cycle trough all your OrdersHistory (in MT4) or History Deals (in MT5), checking their type.
When the type is correct (simply OrderType()>5 in MT4) or DEAL_TYPE_BALANCE (in MT5), you increase a variable in which you sum all deposits.
NOTE: Consider that brokers have different way of calculating swaps and commissions and some of them may figure as deposits/withdrawals, so make your tests.
it seems like mt5 treats withdrawal and deposits as the same type? am i correct? if so then how can it be working? i want calculate total profit percentage of the account so i need to exclude the deposits because there no initial balance value to calculate the percentage profit. is there any other way to do it? thank you
hi , what function and id should i use to get total amount of deposits in the account?
you can run a function through your Account History and sum the trades that is != Magic Number if you are using EAs or OrderType() != OP_BUY||OP_SELL
//+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double DepositSum() { double x=0; for(int i = 0; i < OrdersHistoryTotal(); i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true) { if(OrderSymbol() !=_Symbol && (OrderType() != OP_SELL || OrderType() != OP_BUY) && OrderMagicNumber()!=Magic) { if(OrderProfit()>0) { x += OrderProfit(); } } } } return x; }