What is an Expert Advisor ?
A Forex Expert Advisor (a.k.a. Forex Trading Robot, EA, MT-4 EA, Automated Forex Trading Software) is a mechanical trading system written in the MQL-4 programming language and designed to automate trading activities on the MetaTrader 4 platform. Expert Advisors can be programmed to alert you of a trading opportunity and can also trade your account automatically managing all aspects of trading operations from sending orders directly to your broker’s server to automatically adjusting stop loss, trailing stops and take profit levels.
Expert Advisors for MetaTrader 4 are all unique and different in the rules they follow to enter and exit the market. Expert Advisors eliminate emotional trading decisions that cripple novice trading accounts. Forex Expert Advisors allow investors to exercise a very strict trading system without falling outside pre-programmed parameters and it is this rock solid consistency one of the features that make these programs so attractive to serious investors. Am Expert Advisors can also eliminate the emotional trading decisions that usually cripple novice Forex trading accounts. Forex Expert Advisors exercise unmatched discipline when trading and can be designed to evaluate more parameters at the same time than any human could keep an eye on at once.
All of the technical indicators that are available in the MT-4 platform can be brought to bear in the logic used by an Expert Advisor in almost any way that one can think of thanks to the MQL-4 programming language. All types of moving averages (simple, exponential, etc.), RSI, CCI, etc. You can also create your own custom indicator and call upon it from an Expert Advisor.
There are many different types of MT-4 Expert Advisors depending on their intended application. Some are designed specifically to trade news events and remain out of the market all other times while other MT-4 Expert Advisors are meant to remain active 24x7. Experienced traders who have their own fine tuned manual trading systems sometimes hire MQL-4 programmers to automate their systems thereby creating custom MT-4 Expert Advisors. All expert advisors have the same goal and that is to automate trading operations and generate a profit while doing so.
How does a Forex Expert Advisor work ?
The program works by calculating the different indicators that it was designed to use and take actions when the market conditions meet the correct criteria as described in the source code of the Expert Advisor.
Fore Example. A simple expert advisor may say something like this:
"If the 9 and 20 day moving averages cross with the 9 day MA above the 20 MA and the RSI is higher than 50 then open a long position (buy)"
That is just an example. You can assign countless conditions for entering and exiting the market as well as managing trades for trailing stops and multiple take profit levels.
An MT-4 Expert Advisor is usually divided into three parts: A startup or ‘init’ function, a main function and a ‘deinit’ or cleanup function. The Expert Advisor will run through its startup function once upon startup and will run through its ‘deinit’ or clean-up function once at the end. In the mean time, the MT-4 Expert Advisor program runs through a cycle of its main function over and over with every incoming tick while it is attached to a chart and active. Once running, the Expert Advisor will not start another cycle for a new tick if it is still in the middle of processing the previous one.
Here is a simple outline of what a simple expert advisor could be programmed to do.
(This would be the 'main' part of the EA and takes place every time a tick comes in.)
1- Check my account. Is there enough equity to open a trade? if so, continue. If not, end.
2- Are there any open trades right now?
2a- If there are, do they need to be closed or do they need their trailing stop adjusted? (do so if needed and exit.)
2b- If there are no open trades, are the market conditions right to open one? (do so if needed and exit. )
How to use an Expert Advisor
In order to make use of an Expert Advisor you have to install it on MetaTrader and then attach it to the appropriate chart on MetaTrader 4. This is fairly simple as will be described below. If there are any instructions included with your Expert Advisor you should read them in their entirety.
#1- First, you have to put the Expert Advisor in a place where MetaTrader 4 will be able to use it. In most installations of MetaTrader 4 that place is C:\Program Files\MetaTrader 4\experts The actual Expert Advisor is a file without an icon that ends with .EX4
#2- Now that the Expert Advisor is in the correct location within your computer, re-start MetaTrader 4.
#3- When MetaTrader 4 starts up again you will now see the new Expert Advisor on the left navigation menu.
Can I run more than one Expert Advisor on the same
account/client terminal ?
Yes. You can run multiple instances of an Expert Advisor on the same MetaTrader 4 client terminal. As long as all of the Expert Advisors that you are running in the same client terminal have been designed to get along with each other on the same terminal. (not all Expert Advisors can get along on the same terminal) Mainly because they will try to manage each other’s open trades. Programmers get around this by using magic numbers in the market entrance part of the source code of the Expert Advisor.
There are also platform limitations. Only one Expert Advisor can communicate with the trading server at any one time. If multiple Expert Advisors are active on the same terminal and more than one try to communicate with the trading server you will get "Trade context busy" errors in the logs when this happens if you have too many Expert Advisors on one client terminal.