How to get AccountNumber and AccountName

Back to topics list To post a new topic, please log in or register
avatar
3
Solarix 2015.11.23 20:46
 

Hi folks.

I have a little problem.

if ( IsConnected() ) {  // terminal is online

   AccountNumber();     // returns correct account number

   AccountName();       // returns correct account name

} else {                // terminal is OFFLINE

   AccountNumber();     // returns "0" zero

   AccountName();       // returns empty value

}


The correct number of the account is shown at the top of the terminal window but AccountNumber() returns a zero.

How to get correct Account data when terminal is offline.


Sorry for my english.

avatar
2017
gooly 2015.11.23 21:41 #
 

The server of your broker provides this information. If you are not connected these (and other) functions do not return valid values!

It could even be that for example after a restart of the terminal the Oninit() is executed while the terminal is still in the progress to login and you might get wrong values in this case - imagine a thread race and you haven't won it.

avatar
3
Solarix 2015.11.23 22:22 #
 
gooly:

The server of your broker provides this information. If you are not connected these (and other) functions do not return valid values!

It could even be that for example after a restart of the terminal the Oninit() is executed while the terminal is still in the progress to login and you might get wrong values in this case - imagine a thread race and you haven't won it.

That is 100% correct but any offline terminal can read data such as AccountNumber and AccountName. See Navigator->Accounts.
avatar
145
aakcaagac 2015.11.23 22:34 #
 
Solarix:
That is 100% correct but any offline terminal can read data such as AccountNumber and AccountName. See Navigator->Accounts.
Interesting! While I do see the point, you are otoh misleading here. What you see in Navigator->Accounts are a list of accounts that you can have. E.g. You can have multiple Brokers and accounts. Demo account, Real account etc. These informations are strings (text) stored either in the registry or config files inside Window or MetaTrader, so you can quickly click on them and connect to one of them. The functions you are referring to (above in your code examples) are related to the *currently connected account* and have nothing to do with the strings listed in the Navigator (see it as an address book).
avatar
13000
WHRoeder 2015.11.24 13:50 #
 
Until you connect, log in, and receive the server response, there is no account. Don't call them until you get the first tick.
Back to topics list  

To add comments, please log in or register