• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 5:01pm
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 5:01pm
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

MT4 Strategy Tester initial deposit discrepancies 5 replies

How to get an MA value of first indicators value? 2 replies

how to increase initial deposit in MQ4? 1 reply

IBFX Demo: Initial Deposit inconsitency 11 replies

Scale models of a $1000 initial deposit 2 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
Tags: How to get my Initial Deposit value?
Cancel

How to get my Initial Deposit value?

  • Last Post
  •  
  • Page 1 2
  • Page 1 2
  •  
  • Post #1
  • Quote
  • First Post: Aug 6, 2009 4:58am Aug 6, 2009 4:58am
  •  gwidijanto
  • | Joined Jun 2009 | Status: Member | 7 Posts
Hello,
I have a problem:
I want to get my Initial Deposit value when I opened a new Account, but I don't know how to do it , I need the value to make some calculation in my EA.
Somebody can help me?
thankyou.
  • Post #2
  • Quote
  • Aug 6, 2009 5:27am Aug 6, 2009 5:27am
  •  ecTrade
  • | Joined Jul 2009 | Status: Member | 1,163 Posts
The 'AccountEquity();' function will give your current balance. And, so long as your initial deposit hasn't changed, it will post that.

PHP Code
 double current_balance=AccountEquity(); 

Aso, if you create a variable based on your initial deposit, it will remain the same, and you can call it up whenever you like.

PHP Code
 double initial_deposit=AccountEquity(); 

 
 
  • Post #3
  • Quote
  • Aug 6, 2009 11:57pm Aug 6, 2009 11:57pm
  •  gwidijanto
  • | Joined Jun 2009 | Status: Member | 7 Posts
thank's ecTrade,
however, I need the Initial Deposit value when I opened a new account, using AccountEquity() on the Init() give me the latest balance value, every time I start the EA, not the very first deposit value.
I believe there is some code to do it.
 
 
  • Post #4
  • Quote
  • Aug 7, 2009 12:07am Aug 7, 2009 12:07am
  •  ecTrade
  • | Joined Jul 2009 | Status: Member | 1,163 Posts
Quoting gwidijanto
Disliked
thank's ecTrade,
however, I need the Initial Deposit value when I opened a new account, using AccountEquity() on the Init() give me the latest balance value, every time I start the EA, not the very first deposit value.
I believe there is some code to do it.
Ignored
Maybe you can email your broker? And no, I don't know if or where it stores this information in the program. However, once you do find out what it is, you can store this as a variable inside your EA, and call it up whenever you need to do any calculations. Basically this is all that I was saying.
 
 
  • Post #5
  • Quote
  • Aug 7, 2009 12:42am Aug 7, 2009 12:42am
  •  Ronald Raygun
  • Joined Jul 2007 | Status: 32 y/o Investor/Trader/Programmer | 5,016 Posts
You'd have to get the AccountBalance() Then you need a loop going through every single order in your order history.
 
 
  • Post #6
  • Quote
  • Aug 8, 2009 12:23pm Aug 8, 2009 12:23pm
  •  Irtron
  • | Joined Jul 2008 | Status: MQL Expert | 73 Posts
Quoting gwidijanto
Disliked
Hello,
I have a problem:
I want to get my Initial Deposit value when I opened a new Account, but I don't know how to do it , I need the value to make some calculation in my EA.
Somebody can help me?
thankyou.
Ignored
Deposit/withdrawal orders have type 6.
Search order history for orders with that type.
 
 
  • Post #7
  • Quote
  • Aug 8, 2009 10:02pm Aug 8, 2009 10:02pm
  •  gwidijanto
  • | Joined Jun 2009 | Status: Member | 7 Posts
Hi Ronald Raygun and Irtron, thank's for your reply,
I 've been thinking about that too, but couldn't find the right code/script to do it, since I'm still learn how to make an EA, if I'm not asking too much, would you mind giving me the script for this?

regards.
 
 
  • Post #8
  • Quote
  • Aug 9, 2009 8:52am Aug 9, 2009 8:52am
  •  Irtron
  • | Joined Jul 2008 | Status: MQL Expert | 73 Posts
Quoting gwidijanto
Disliked
Hi Ronald Raygun and Irtron, thank's for your reply,
I 've been thinking about that too
Ignored
About what exactly?
Quote
Disliked
if I'm not asking too much, would you mind giving me the script for this?
Inserted Code
    for (int i = OrdersHistoryTotal() - 1; i >= 0; i--)
        if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY))
            if (OrderType() == 6)
                OrderPrint();
 
 
  • Post #9
  • Quote
  • Aug 9, 2009 12:43pm Aug 9, 2009 12:43pm
  •  Ronald Raygun
  • Joined Jul 2007 | Status: 32 y/o Investor/Trader/Programmer | 5,016 Posts
Inserted Code
int Total = OrdersTotal();
double BalanceUsed = AccountBalance();
int HistoryTotal = OrdersHistoryTotal();
double Balance;

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

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

Print("Your starting balance was: "+Balance);
 
 
  • Post #10
  • Quote
  • Aug 9, 2009 3:46pm Aug 9, 2009 3:46pm
  •  Irtron
  • | Joined Jul 2008 | Status: MQL Expert | 73 Posts
Quoting Ronald Raygun
Disliked
Inserted Code
int Total = OrdersTotal();
double BalanceUsed = AccountBalance();
int HistoryTotal = OrdersHistoryTotal();
double Balance;
....
        Balance = Balance - OrderProfit();
....
        Balance = Balance - OrderProfit();
....
Print("Your starting balance was: "+Balance);
Ignored
I gave you three apples. You've eaten two. How many apples do you have?
 
 
  • Post #11
  • Quote
  • Aug 9, 2009 5:18pm Aug 9, 2009 5:18pm
  •  Ronald Raygun
  • Joined Jul 2007 | Status: 32 y/o Investor/Trader/Programmer | 5,016 Posts
Quoting Irtron
Disliked
I gave you three apples. You've eaten two. How many apples do you have?
Ignored
Oops!

This is what happens when you don't debug your code. haha
 
 
  • Post #12
  • Quote
  • Aug 9, 2009 6:28pm Aug 9, 2009 6:28pm
  •  luxinterior
  • Joined Nov 2006 | Status: MT4 EA Coder Since 2006 | 300 Posts
The only issue I see with this (or any approach really) is you'll need to have your complete account history available in your 'Account History' tab which you'll have to do manually. By the time you've done that you could have just read it and entered it into your EA as an external variable. Of course I'm not really clear why you 'need' to get your initial deposit.


Good luck

Lux
MT4 EA, Indicator and Alert Coder Since 2006
 
 
  • Post #13
  • Quote
  • Aug 9, 2009 6:51pm Aug 9, 2009 6:51pm
  •  ecTrade
  • | Joined Jul 2009 | Status: Member | 1,163 Posts
The only problem with the Account History tab (at least with my terminal) is that it's automatically reset at the beginning of the month, and this is as far back as I can go to access any information. Not unless it can be set up differently?
 
 
  • Post #14
  • Quote
  • Aug 9, 2009 7:07pm Aug 9, 2009 7:07pm
  •  charmforex
  • | Membership Denied | Joined Jan 2009 | 2 Posts
Initial account balance is not something you can get from variable or calculate somehow.
Initial account balance is a concept for demo accounts mostly, because when you test a strategy you open a new demo account.
There is no sensible reason to calculate something from EA using that IAC(initial account balance), because it is not normal to open a new real account every time you use different EA. It would be much better to place a extern parameter where you can specify initial balance for testing. By that way you can use this EA on real accounts too.

If you tell me what you want to calculate, I can tell you the best way to do it. But I am sure that you are at wrong way.
 
 
  • Post #15
  • Quote
  • Aug 9, 2009 7:08pm Aug 9, 2009 7:08pm
  •  ecTrade
  • | Joined Jul 2009 | Status: Member | 1,163 Posts
Okay, if you do a right hand click in the "context" area (where the data is displayed), a menu will pop up that will give you the option to select "All History."
 
 
  • Post #16
  • Quote
  • Aug 9, 2009 10:50pm Aug 9, 2009 10:50pm
  •  gwidijanto
  • | Joined Jun 2009 | Status: Member | 7 Posts
Hi Ronald Raygun and Irtron, wow... thank's for your script,
after some minor change for Ronald raygun's script:

int Total = OrdersTotal();
double BalanceUsed = AccountBalance();
// HistoryTotal = OrdersHistoryTotal(); -->couldn't use it, always error
double Balance;
for (int i = 0; i < Total; i++)
{
OrderSelect(i,SELECT_BY_POS, MODE_TRADES); -->not POSITION
if(OrderType() == OP_BUY || OrderType() == OP_SELL)
{
Balance = Balance - OrderProfit();
}
}
for (int p = 0; p < OrdersHistoryTotal(); p ++)
{
OrderSelect(i,SELECT_BY_POS, MODE_HISTORY);-->not POSITION
if(OrderType() == OP_BUY || OrderType() == OP_SELL)
{
Balance = Balance - OrderProfit();
}
}
Print("Your starting balance was: "+Balance);

both script are working, unfortunately both doesn't show the correct Initial deposit value ...
I think the problem is : I run multi pair (EURUSD,GBPUSD,EURJPY and USDJPY) for one account.
I already tried to get it worked by adding a script, something like this:
if (OrderSymbol()==Symbol() && OrderMagicNumber() == Magic)
{ .....
but failed,
If you don't mind, please fix this problem, since it is almost woking.

Hi charmforex,
yes, I use it for demo account, I need it because I don't want to type it manually every time I open a new account,
so it will be better if there is a way to do it inside the EA.

thankyou for your help.
 
 
  • Post #17
  • Quote
  • Aug 9, 2009 11:39pm Aug 9, 2009 11:39pm
  •  luxinterior
  • Joined Nov 2006 | Status: MT4 EA Coder Since 2006 | 300 Posts
As I mentioned before you'll only be able to retrieve what you have in your LOCAL account history (via clicking the 'Account History') tab so you'll have to refresh it to ALL HISTORY manually every time you open up MT4. By the time you've done that you could have just entered it as an external variable.

In short, you're wasting your time.

Lux
MT4 EA, Indicator and Alert Coder Since 2006
 
 
  • Post #18
  • Quote
  • Edited 12:27am Aug 10, 2009 12:02am | Edited 12:27am
  •  ecTrade
  • | Joined Jul 2009 | Status: Member | 1,163 Posts
Quoting gwidijanto
Disliked
Hi charmforex,
yes, I use it for demo account, I need it because I don't want to type it manually every time I open a new account,
so it will be better if there is a way to do it inside the EA.

thankyou for your help.
Ignored
Is this so you can keep track of your profits and losses on each individual account? Of course if each individual account has a separate folder containing its own EA's (this is usually how it's setup, initially I think), you only need to retrieve the initial deposit only once, and store it as a variable within an EA specific to that account.
 
 
  • Post #19
  • Quote
  • Aug 11, 2009 5:50am Aug 11, 2009 5:50am
  •  gwidijanto
  • | Joined Jun 2009 | Status: Member | 7 Posts
Hi ectrade,
No, I just want to retrieve the deposit value as you can see it at Account History tab (as per Luxinterior said),
at the very first/last row. (for example: Balance ....Deposit 5000), that 5000 is the value I want.
If there is a code like: AccountDeposit() ......
thank's
 
 
  • Post #20
  • Quote
  • Nov 25, 2018 8:39pm Nov 25, 2018 8:39pm
  •  MrOuro
  • | Joined Nov 2018 | Status: Junior Member | 1 Post
Ola Não sei se alguém já conseguiu!!!
Segue código

Inserted Code
double valor_depositado()
{
   double retorno = 0;
   for (int i = OrdersHistoryTotal() - 1; i >= 0; i--)
   {
      if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY))
      {
         if (OrderType() == 6)
         {
            Print("Deposito: ",OrderProfit());
         }
      }      
   }   
   
   return (retorno);
}
 
1
  • Platform Tech
  • /
  • How to get my Initial Deposit value?
  • Reply to Thread
    • Page 1 2
    • Page 1 2
0 traders viewing now
  • More
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2023