Azkron:
Hello!
I have a demo account and in my client Trade tab I can see that I have 10000 Balance, Equity, and Free margin but when I call AccountInfoDouble(ACCOUNT_BALANCE) in my Expert Advisor I get returned 0, this also happens with Equity and Free Margin.
Might this be because this is a demo account or is it something else?
I don't think. How did you check the returned value ?
Icham Aidibe:
I don't think. How did you check the returned value ?
printf("ACCOUNT_BALANCE = %d", AccountInfoDouble(ACCOUNT_BALANCE)); printf("ACCOUNT_CREDIT = %d", AccountInfoDouble(ACCOUNT_CREDIT)); printf("ACCOUNT_PROFIT = %d", AccountInfoDouble(ACCOUNT_PROFIT)); printf("ACCOUNT_EQUITY = %d", AccountInfoDouble(ACCOUNT_EQUITY)); printf("ACCOUNT_MARGIN = %d", AccountInfoDouble(ACCOUNT_MARGIN));
They all print 0
Azkron:
Use : %g
- When you post code please use the CODE button (Alt-S)!
(For large amounts of code,
attach it.)
Please edit
your post.
General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor - Where do you have that code? Probably in OnInit.Don't try to use any price or server related functions in OnInit (or on load,) as there may be no connection/chart yet:
- Terminal starts.
- Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
- OnInit is called.
- For indicators OnCalculate is called with any existing history.
- Human may have to enter password, connection to server begins.
- New history is received, OnCalculate called again.
- New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent and prices are valid.
- d, i, u, o, x, X are all the integer group. Try %f or %g
Common Functions / PrintFormat - Reference on algorithmic/automated trading language for MetaTrader 5
whroeder1:
- When you post code please use the CODE button (Alt-S)! (For large amounts of code, attach it.) Please edit your post.
General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor - Where do you have that code? Probably in OnInit.
- d, i, u, o, x, X are all the integer group. Try %f or %g
Common Functions / PrintFormat - Reference on algorithmic/automated trading language for MetaTrader 5
Thanks, now I print it the first time OnTick() triggers and the values look correct.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello!
I have a demo account and in my client Trade tab I can see that I have 10000 Balance, Equity, and Free margin but when I call AccountInfoDouble(ACCOUNT_BALANCE) in my Expert Advisor I get returned 0, this also happens with Equity and Free Margin.
Might this be because this is a demo account or is it something else?