Previous: Part 1 : Get started.
Last update: 22 April 2023
Now we're going to add indicators to this EA.
Indicators supply the EA with the information it needs to make trading decisions, both for opening aan order and closing an order. Indicators are added to the EA by you, thereby creating a library (or a 'list') of information for your EA. This list of indicators is a centralized place of information which your EA will use. Once the EA uses these indicators for trading decisions and you edit an indicator, by changing the indicator's parameters, it will affect all of the EA's trading decisions which are referencing this indicator.
To add an indicator, click 'Add' on your indicators list.
You're offered to choose from all standard MetaTrader indicators sorted by alphabet. If you have uploaded your own custom indicators these will also be available at the top of the list. The number and variety of indicators you can add is unlimited.
It's a common scenario that you'll want to use the same indicator multiple times, with different parameter values. To achieve this, you will add the indicator multiple times, with different values and a different name per indicator. For example, you can name one indicator 'EMA 5' and another indicator 'EMA 10'. Set the 'Period' parameters of the first indicator to the value 5 and the same parameters for the second indicator to value 10.
For our EA, we're going to add the "Moving Average" indicator. In fact, we will add this indicator 2 times. Do you remember our goal for your EA, stated in the beginning of this Tutorial? We're using 2 different variants of EMA.
Now, find the "Moving Average" indicator in the list:
After selecting the indicator, you will see all the parameters of the indicator. You should be familiar with these parameters, because these are the same parameters as shown in MetaTrader when adding an indicator to the chart. The values you enter here will be the values your EA will use for this indicator, at every trading decision which is referencing this indicator.
This is how we've setup the indicators (parameters not mentioned keep their default value):
After you've set up all indicators, you should have a list of indicators which looks like this:
We've now added all indicators and now we can move on to the next part.