MQL4 TUTORIAL BASICS – SIMPLE ACCOUNT CHECK (translated with AI which is a bit scary)

video
play-sharp-fill

In this video we want to take a look at how you can limit the account number for the use of an Expert Advisor, so that only the account number can be used that you allow. So let’s take a look at how you can program something like this in MQL4. We are currently seeing an output on the chart that says the account number is wrong. And if you click on Journal here, we can also see that we have a license problem.

 

So let’s take a look at how you can program something like this in MQL4. Okay, this is now our simple example of an Expert Advisor that is able to check and limit an account number. We start here with the declaration for an integer variable called account number. Then comes the ontick function, which is always called up in the Expert Advisor when there is a change in the price. And here we use an if-question to call up the function account number and check whether it is correct or whether it is wrong. If it is correct, then we would get the output that the account number is correct. In the other case, if the return value is false, then we get the message that the account number is wrong. The actual function is a bool function, which means it can only return two values.

 

It has the name check account number and this addition here export, which would allow us to use the function in a library and import it into an Expert Advisor. We start by creating a bool variable with the name isLicensedAccount and giving the initial value here false. Then we get the account number with the function accountInfoInteger and transfer this to the parameter accountLogin. This returns the account number that is used and we now check here whether this account number matches the account number value that we transfer in our Expert Advisor. If that is the case, then we set our variable here to true and make an output that tells us that we are using the correct account number. In the other case, if our variable has the value wrong, then we use the print command to issue a license problem. And finally, we use the return function here to return the return value of our variables here to the onTick function, which then shows us the corresponding return value on the chart. By the way, this complete example would also work in mql5 and if you haven’t switched to MetaTrader 5 yet, it will be real time for that.

 

For the moment, let’s click on Compile or press the F7 key. This should work without errors and if that is the case with you, then you can click on this little button up here or press the F4 key to return to the MetaTrader. Okay, if everything worked well, then you should now have an Expert Advisor with which you can test it. I have the wrong account number here. We change that now, log in with the correct account and if we stop the test now and restart it again, then we should see the account number is correct, the entries in the journal also fit now and you learned in this short video how you can create an Expert Advisor with a few lines in mql4 that is able to ask for a certain account number to protect against the use of illegitimate account numbers.

 

And you programmed that yourself with these few lines here in mql4. That is how you can create an Expert Advisor with a few lines in mql4 that is able to ask for a certain account number to protect against the use of illegitimate account numbers. And you programmed that yourself with these few lines here in mql4. That is how you can create an Expert Advisor with a few lines in mql4. And you programmed that yourself with these few lines here in mql4.