MQL5 TUTORIAL BASICS – 76 SIMPLE ACCOUNT INFORMATION

video

In this video, we are going to create an expert advisor that is able to output account-related information directly on our chart.
To get started please click on a little I can here or press F4 on your keyboard, now you should see the Metaeditor window until you want to click on file, new file, expert advisor from template, continue, I will call this file, simple account info, click on continue, continue and finish.
Now you can delete everything above the ontick function and the two comment lines here.
We start with getting the account server information that is done by using account info string and the parameter we are going to use is account underscore server, so in my case, the return value is MetaQuotes Demo for this account.
Account info is available for string, for integer and for double values, so let’s continue with another string value.
Account info string account underscore currency will return the currency that we are using, in my case I’m using Euro.
Another string value is the account name, we can get that by using account info string account underscore name, my account name is Raimund Bauer.
Now let’s continue with an integer value for the account trade mode, we get the integer value by using account info integer and the account trade mode is something that will return a value for the trade mode that is either zero, one or two, let’s see if we can get the values.
Here is the reference entry for the trade mode and if you click on this little link you will see this can return demo, contest or real account but as the return value is an integer value it would be, zero, one or two. I would like to create a readable account trade mode version that can output a text and if the account trade mode equals zero I would like to see the text, demo account, if the return value for account trade mode is one that would be a contest account for trading contests, and if the account trade mode equals two that would be a real account.
Now let’s continue with the account login, this is another integer value and it returns the account number.
The next one is called account company, we get it by using account info string account underscore company, in my case, it’s the MetaQuotes Software Corporation.
The account leverage is also very interesting, this again is an integer value, the parameter is account underscore leverage and in my case, it’s five hundred, actually, it’s 1 to 500, this is a very high leverage.
The next one is also very interesting, it will tell us how many orders we can have, we get it by using account info integer account underscore limit underscore orders, in my case I can have 200 orders.
Now let’s get the free account margin, this is the first time we use account info double, the parameter is account underscore margin underscore free, here is the output for this account.
Let’s get two bool values, this looks a little bit strange because this is a bool but we are going to use account info integer to get it.
The first one is for the account underscore trade allowed property, this is going to tell us if we are allowed to trade at all.
And the second one is going to tell us if we are allowed using expert advisors and last but not least I would like to have the account margin mode, this is an integer value and it’s important because, for the type of automated trading that we do we need to have a hedging account, you can find out if your account is a hedging account by looking at this text, you should see the word hedge here.
And we learn that zero stands for netting mode, a one would mean we have an exchange mode and two is the desired hedging mode, I can never remember that so let’s create a readable account margin mode.
If the account margin mode equals zero I would like to see the output netting mode, for one it will output exchange mode, and for two this is the hedging mode.
Now let’s create a chart output for each of the values, I have used the readable account trade mode and the readable account margin mode here, so I don’t see any numbers but real text and that’s about it.
Well, if this was too fast for you or if you have no idea what all the code here does you maybe want to watch one of the other videos in this basic video series or maybe even the premium course on our website might be interesting for you.
Click on the compile button, you shouldn’t see any errors here and if this is the case please click on a little icon here or press F4 to go back to Metatrader.
And inside Metatrader we just use an empty chart, please pick the new file, simple account info here in the Navigator window and drag it on the chart, let’s click on okay and here are my account settings, let’s change the account and see what happens, and now we see this is a real account, it’s from RoboForex Ltd, it actually supports 500 orders and we see different values for all the other things here and in this little video you have learned how to create an expert advisor that is able to output all the account-related information directly on your chart and you have coded it yourself with a few lines of mql5 code.