Issue: AccountInfoDouble(ACCOUNT_BALANCE) returns 0 all the time.

 

Hello everyone,

I'm developing an EA and upon trying to get the account balance I'm getting the value 0. Does anyone know which is the reason of this?

Here there is an example of how I'm getting a 0.

void OnInit()
  {
   Print("OnInit: ", AccountInfoDouble(ACCOUNT_BALANCE));
  }

void OnTick()
  {
   Print("OnTick: ", AccountInfoDouble(ACCOUNT_BALANCE));
  }

The output is the following:


Thank you very much.

 
I will add that the account does not have a balance of 0.
 
Kevin de la Coba Malam #:
I will add that the account does not have a balance of 0.

Please, share the entire code of it. So we can have a deeper understanding. The AccountInfoDouble() function should work fine. Is this account of yours valid?

 
void OnInit()
  {
   Print("OnInit: ", AccountInfoDouble(ACCOUNT_BALANCE));

don't try to use any price (or indicator) or server related functions in OnInit (or on load or in OnTimer before you've received a tick), as there may be no connection/chart yet:

  1. Terminal starts.
  2. Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
  3. OnInit is called.
  4. For indicators OnCalculate is called with any existing history.
  5. Human may have to enter password, connection to server begins.
  6. New history is received, OnCalculate called again.
  7. A new tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.