MQL4 Reference MQL4 programs Trade Permission
Trade PermissionTrade AutomationMQL4 language provides a special group of trade functions designed for developing automated trading systems. Programs developed for automated trading with no human intervention are called Expert Advisors or trading robots. In order to create an Expert Advisor in MetaEditor, launch MQL4 Wizard and select the option "Expert Advisor (template)". It allows you to create a template with ready-made event handling functions that should be supplemented with all necessary functionality by means of programming. Trading functions can work only in Expert Advisors and scripts. Trading is not allowed for indicators. Checking for Permission to Perform Automated TradingIn order to develop a reliable Expert Advisor capable of working without human intervention, it is necessary to arrange a set of important checks. First, we should programmatically check if trading is allowed at all. This is a basic check that is indispensable when developing any automated system. Checking for permission to perform automated trading in the terminalThe terminal settings provide you with an ability to allow or forbid automated trading for all programs. You can switch automated trading option right on the terminal's Standard panel:
Sample check:
Checking if trading is allowed for a certain running Expert Advisor/scriptYou can allow or forbid automated trading for a certain program when launching it. To do this, use the special check box in the program properties. Sample check:
Checking if trading is allowed for any Expert Advisors/scripts for the current accountAutomated trading can be disabled at the trade server side. Sample check:
If automated trading is disabled for a trading account, trading operations of Expert Advisors/scripts are not executed. Checking if trading is allowed for the current accountIn some cases, any trading operations are disabled for a certain trading account neither manual nor automated trading can be performed. Sample check when an investor password has been used to connect to a trading account:
AccountInfoInteger(ACCOUNT_TRADE_ALLOWED) may return false in the following cases:
See also Client Terminal Properties, Account Properties, Properties of a Running MQL4 Program |