AccountInfoInteger fails

 

Hello,

in my indicator i need to query login.

long my_login=AccountInfoInteger(ACCOUNT_LOGIN);

This happens outside OnInit. When multiple charts have this indicator attached, it happens in some charts, that my_login=0.

So 

AccountInfoInteger(ACCOUNT_LOGIN);

returns 0;

 
chinaski:

Hello,

in my indicator i need to query login.

This happens outside OnInit. When multiple charts have this indicator attached, it happens in some charts, that my_login=0.

So 

returns 0;

Where is it in your code?

 
Keith Watford:

Where is it in your code?

Within the stack of OnTimer

 
This happens not in all charts, but the more charts have the indicator attached, the more fails, when starting MetaTrader 4.
 
chinaski: Within the stack of OnTimer

Don't try to use any price or server related functions in OnInit (or on load), 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. New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.

Don't call in OnTimer until you've received a tick.

 
William Roeder:

Don't try to use any price or server related functions in OnInit (or on load), 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. New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.

Don't call in OnTimer until you've received a tick.

Thank you for this list.

Questions:

1. Does this list also apply for MT5 ?


2. Does it mean, with SECOND call of

OnCalculate

i can be sure connection established  and account information available AND realtime data available ?

Thank you