How to trade by Expert Advisor?
1. Prepare Expert Advisor file.
2. Expert Setup.
Launch of an Expert Advisor.
1.Prepare Expert Advisor file.
Paste Expert Advisor in the /EXPERTS folder of the client terminal.
Before using of experts, one has to set them up first. Working parameters common for all experts are defined in the client terminal settings window. This window can be opened by the "Tools — Options" menu command or by pressing of accelerating keys of Ctrl+O. To set up expert parameters, one has to select the "Expert Advisors" tab. The following settings are available in it:
Enable Expert Advisors
This option allows to enable or disable the use of all experts. If it is disabled, the start() function will stop execute for all experts when a new tick incomes. At that, the smileys at the expert names in the upper right corners of charts will be replaced with daggers. To enable experts, one has to flag this option and press "OK". They will start functioning when a new tick incomes, and daggers in the upper right corners will be replaced with smileys again.
the expert will start function when a new tick incomes, and it often completes its work before the next tick incomes. Disabling of experts does not interrupt working of those that are active already;
this option covers only expert advisors and does not allow to disable custom indicators and scripts automatically.
Disable experts when the account has been changed
This option represents a safety tool that disables experts when the account has been changed. It can be useful, for example, when one switches from a demo account to a real one. To enable it, one has to flag it and press "OK".
Disable experts when the profile has been changed
A large amount of information about the current settings of all charts of the workspace is saved in profiles. Particularly, information about the attached experts is saved in profiles. Experts included into a profile will start working when a new tick incomes. Having enabled this option, one can disable launching of experts when the profile has been changed.
Allow live trading
Experts can work automatically, without trader's participation. They can both analyze price changes and trade. This option is intended for limiting of trading functions of experts. These limitations can be useful for testing of analytical capacities of an expert in the real-time mode (not to be mixed up with testing of an expert on history data).
Ask manual confirmation
This option will only be enabled if experts are allowed to trade. If this option is enabled and the expert tries to trade, one will be able to confirm the trade or interrupt it manually. In other words, trading activities of experts can be managed through this manual confirmation option. This can be useful for testing of trading functions of an expert in the real-time mode (not to be mixed up with testing of an expert on history data)..
Allow DLL imports
Experts can use DLLs to enlarge their functionalities. If this option is enabled, the libraries can be used without any limitations. Disabling of the option results in that no expert can use any external DLLs. It is recommended not to allow DLL imports when working with unknown experts.
Confirm DLL function calls
Allow external experts imports
This option will only be enabled if DLL imports are allowed. It allows to control over execution of each called function manually. If it is disabled, the imports from external libraries will not be controlled. This option is recommended to be enabled when working with unknown experts.
If there is a need to export functions from other experts or MQL4 libraries during the expert functioning, one has to enable this option. If it is disabled, no expert already launched will be able to call functions from other MQL4 programs. This option is recommended to be disabled when working with unknown experts.
3.Launch of an Expert Advisor
After general parameters have been set up, experts can be launched. To do so, it is enough just to attach the expert to the chart. The "Attach to a chart" command of the "Navigator — Expert Advisors" window context menu or double click with the left mouse button on the selected expert in the same window allows to impose it into the active chart. "Drag'n'Drop" technique allows to impose the expert into any chart. At that, the window of the expert special settings will appear. In its "Common" tab, it is possible:
- positions — select the direction of position opening:
- Long&Short — in both directions;
- Only Long — only for buying;
- Only Short — only for selling.
- Enable alerts — enable/disable the expert to alert;
- Disable alert once hit — disable alerts after the first alert has been given;
- Allow live trading — enable/disable live trading;
- Ask manual confirmation — request for manual confirmation of position opening when trading;
- Allow DLL imports — enable/disable imports of functions from DLL files;
- Confirm DLL function calls — request for confirmations at each function call from DLL files;
- Allow import of external experts — enable/disable calling of functions from external experts.
External variables of the expert can be changed in the "Inputs" tab. these are variables of extern class. To save an input, one has to double-click with the left mouse button on its value and write the new one. At that, one can change the value of each variable or download the set of inputs already saved (the "Load" button). One can save the current set of external variables using the button of the same name.
The "Reset" button returns all default settings. Parameters defined in the terminal settings are given in the "Common" tab. And parameters defined in the program source code are set as inputs. To attach the expert with the new parameters to a chart, one has to press "OK". To cancel the expert imposing, one has to press the button of the same name.
Only attached experts can be set up individually. However, while current executing, the window of the expert properties cannot be opened. This can be done only during intervals between calls of the start() function. At that, the expert will not be launched until its properties window is closed. If the expert inputs were changed, the expert will be re-initialized with its new inputs at pressing of "OK".
After an expert has been set up, it will be initialized and, as soon as a new tick incomes, execute. Expert is attached if its name and a smiley can be seen in the upper right corner of the chart. If live trading is disabled in the expert settings, a :) will appear instead of the smiley. A dagger (x) means that all experts are disabled.
Only one expert can be attached to a chart. If another expert is imposed, the previous one will be deleted from the chart.