double balance = AccountInfoDouble(ACCOUNT_BALANCE);
See Here.
Documentation on MQL5: Account Information / AccountInfoDouble
- www.mql5.com
Account Information / AccountInfoDouble - Reference on algorithmic/automated trading language for MetaTrader 5
I had some issue too.
Choose another demo account with broker then it works.
Don't use Metaquotes demo account, not reliable (at least for me).
Kok Hoong Cheang: I have no idea why the following code reveals account balance is 0.
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, account information and prices are valid.
Thanks, putting the code in OnCalculate/OnTick works; I was putting it OnChartEvent
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
Hi, how do I get the account balance in a demo account?
The following gives me 0.....maybe there's another way to call it?