[ Ссылка ]
Introduction to Secure Account Number Check in Expert Advisor (00:00 - 00:12)
Introduction to creating an Expert Advisor that secures your account number, ensuring it's only used on specific accounts.
Declaring the Account Number Variable (00:12 - 00:22)
Explanation of how to declare a variable to store the account number for comparison.
Utilizing the OnTick Function (00:22 - 00:44)
Overview of the OnTick function, which is called automatically by MetaTrader on receiving a new tick, and its role in calling the account check function.
The Check Account Number Function (00:44 - 01:04)
Detailed walkthrough of the check account number function, including declaring variables and setting initial values.
Retrieving and Comparing Account Information (01:04 - 01:26)
Instructions on using the account info integer function to retrieve account number and type, and how to compare these with predetermined values.
Handling True and False Account Comparisons (01:26 - 01:58)
Steps to handle the outcomes of the account number comparison, including setting variables and printing messages to the terminal.
Compiling the Code and Testing in MetaTrader (01:58 - 02:12)
Guidance on compiling the code and returning to MetaTrader for testing.
Conclusion and Practical Application (02:12 - 03:03)
Concluding remarks on the purpose and application of the code, and a demonstration of running the Expert Advisor on the correct account.
In this video, we are going to create a little simple expert advisor to secure your account number. So nobody else will be able to use your expert advisor if not a certain type of account is used. So let's see how that can be done with MQL5.
The account number variable: the first part of the code is the declaration of the account number variable. This variable is used to store the account number that is to be compared against the predetermined number. The OnTick function: the OnTick function is a special function that is automatically called by the Metatrader platform whenever a new tick is received. In this case, the Ontick function is used to call the check account number function, which will be discussed in more detail later. The check account number function: The check account number function is the main function used to verify the account number. It begins by declaring the is licensed account boolean variable and setting it to false. This variable is used to store the result of the comparison between the account number and the predetermined number. The next line of code uses the account info integer function to retrieve the account number from the Metatrader platform and store it in the account number variable. The following line of code uses the account info integer function to retrieve the account type from the Metatrader platform and store it in the account type variable. The next part of the code is an if statement that compares the account number variable to the predetermined number.
If the comparison returns true, then the is licensed account variable is set to true and a message is printed to the terminal window. The last part of the code is an if statement that checks the value of the is licensed account variable. If the value is false, then a message is printed to the terminal window. Finally, the function returns the value of the is licensed account variable. You can now press F7 to compile your code and return to the Meta trader by pressing F4. Conclusion: This MQL5 code is used to verify if an account number is true or false. It does this by comparing the account number to a predetermined number and then returning a boolean value of true or false depending on the result of the comparison.
Okay, so far so good. If everything worked out as it should, you should now be able to run the expert advisor on the correct account. So let's change that here. I will stop the strategy tester. Let's pick the right account here, restart the test, and now we get the output, the account number is true. And in this little video, you have learned how to hard code an account number into your expert advisor to make sure that it is not used by anybody else. Thank you for watching and I will see you in the next video.
Ещё видео!