Setting a moving average crossing strategy for TradeBuilderMT5

6 October 2018, 07:18
Sergey Deev
0
420

The TradeBuilderMT5 Expert Advisor is designed to build a trading system based on an arbitrary set of technical MT5 indicators.

The main goal of this advisor is to save the trader, who is in the process of finding his own grail, from having to constantly order advisors for "new" strategies. It is enough to set up an existing adviser and evaluate the profitability of the trading idea.

So, today is the first lesson of setting an adviser. We will build the simplest system opening deals at the intersection of the moving averages EMA (7) and EMA (21).

The question of how to buy an adviser or download a trial version will be lost, leaving it to the administration of the mql5, and specifically to this article.

In the MT5 terminal, open the tester settings and select our advisor. It should look something like this:Настройки тестера стратегий

Next, go to the tab of the input parameters of the tester and make the settings similar to the one shown in the figure below:

Сигнал на покупку по пересечению скользящих средних

The numbers in the picture indicate the following:

  1. first line indicator is selected - MA
  2. current time period selected
  3. blank action with the first line
  4. first line parameters (more on this below)
  5. the last closed bar is set
  6. second line indicator
  7. second time frame
  8. action for the second line crossing up
  9. second line parameters
  10. second line bar
  11. empty indicator is selected (required if algorithm is completed)

Similarly, we set up a sell signal. The difference is only in the action of the second line - choose CrossDown

Сугнал на продажу по пересечению скользящих средних

Next, we check that the EmptyIndicator is selected for all other signal settings and we can run the advisor.

Now about the parameters of the indicators. Here we need to refer to the documentation section, specifically about the moving average. We have the following description:

int  iMA( 
   string               symbol,            // имя символа 
   ENUM_TIMEFRAMES      period,            // период 
   int                  ma_period,         // период усреднения 
   int                  ma_shift,          // смещение индикатора по горизонтали 
   ENUM_MA_METHOD       ma_method,         // тип сглаживания 
   ENUM_APPLIED_PRICE   applied_price      // тип цены или handle 
   );

The first two parameters do not interest us - we set them in our settings. There are ma_period, ma_shift (there should be no questions here), ma_method and applied_price. For the second two parameters, people who program a little on mql will also have few questions, but we will consider the general case. Constants are available on the documentation page and are listed below. Their numerical expression is numbered from top to bottom of zero. For example, MODE_SMA = 0, MODE_LWMA = 3. In our case, the string parameter '21, 0,1,0 'means the period of the sliding 21, offset 0, MODE_EMA, PRICE_CLOSE.

ENUM_MA_METHOD

ID

Description

MODE_SMA

Simple averaging

MODE_EMA

Exponential averaging

MODE_SMMA

Smoothed averaging

MODE_LWMA

Linear-weighted averaging


ENUM_APPLIED_PRICE

ID

Description

PRICE_CLOSE

Close price

PRICE_OPEN

Open price

PRICE_HIGH

The maximum price for the period

PRICE_LOW

The minimum price for the period

PRICE_MEDIAN

Median price, (high + low)/2

PRICE_TYPICAL

Typical price, (high + low + close)/3

PRICE_WEIGHTED

Average price, (high + low + close + close)/4


Having dealt with the parameters, we will slightly complicate our strategy, since I do not like work without SL. Make the settings in accordance with the picture:

Стоп-лосс Buy

The numbers in the picture indicate:

  1. Lowest price calculation selected
  2. time interval specified
  3. empty action
  4. initial bar
  5. section length in bars
  6. empty indicator

For Sell Stop Loss, set up a Highest price:

стоп-лосс Sell

Now we run the adviser and rejoice ..

The set file is attached.

In the next article, we will look at how to add signal filtering with an indicator of a higher time frame.

Share it with friends: