How to Get the Intial Deposited Amount? I tried But!!!

Back to topics list To post a new topic, please log in or register
avatar
273
sheriffonline 2015.08.03 07:11
 
int Total = OrdersTotal();
double BalanceUsed = AccountBalance();
double Balance;

for (int i = 0; i < Total; i++)
    {
    OrderSelect(i,SELECT_BY_POS, MODE_TRADES);
    if(OrderType() == OP_BUY || OrderType() == OP_SELL)
        {
        Balance = Balance - OrderProfit();
        }
    }

for (int p = 0; p < HistoryTotal(); p ++)
    {
    OrderSelect(i,SELECT_BY_POS, MODE_HISTORY);
    if(OrderType() == OP_BUY || OrderType() == OP_SELL)
        {
        Balance = Balance - OrderProfit();
        }
    }

Comment("Intial Deposit was: "+Balance);

What wrong with this code?

I don't get the deposit amount. i want to find intial deposit amount to calculate the drawdown to avoid risk in trades to reduce drawdown.

Help on this issue.

avatar
12985
WHRoeder 2015.08.03 15:38 #
 
  1. open orders do not change AccountBalance
  2. There is no functon HistoryTotal()
  3. profit = OrderProfit() + OrderCommission() + OrderSwap()
  4. Check your return codes (OrderSelect) What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
avatar
273
sheriffonline 2015.08.03 18:10 #
 

Got the Code here: https://forum.mql4.com/62016

for(int i = OrdersHistoryTotal() -1; i >= 0; i--)
   {
   if(OrderSelect(i, SELECT_BY_POS, MODE_HISTORY))
      {
      if (OrderType() == 6)
         {
         Comment("The Deposit Was ", OrderProfit(), " ", AccountCurrency());
         }
      }
   }


But it works only when we have opened All History on History Tab.

is there any other solutions to get the intial deposit?

Back to topics list  

To add comments, please log in or register