Moving Average

Hello, dear traders! Today we will consider the Moving Average trading advisor. The adviser’s algorithm is obscenely simple: it is based on one moving average, as you understand from its name, the Moving Average indicator. In this blog, we will be using the broker Libertex

Before moving on to continue studying the Expert Advisor, familiarize yourself with the Moving Average indicator. If you know how it works, then everything is in order. Move on.

Parameters of the Moving Average Expert Advisor

Run it. The adviser is in the standard set of the MT4 terminal. In the terminal navigator field, click on the “Expert Advisors” tab, find the Moving Average and drag it onto the chart with the mouse. Click on the “Inputs” tab:

 Moving Average Trading Expert Advisor

Let’s dwell on them in more detail:

Lots (default 0.1) – which lot will initiate the transaction? When setting a new value, the lot step should be 0.1;

Maximum Risk: the default risk per trade is 0.02, that is, 2%. You can learn more about risks from the article “Money management as a major key to success in Forex“;

The Decrease Factor (default 3.0) is the degree to which a lot of the next trade will decrease if a losing one is received. This parameter allows you to lower your risks in the event of a failed transaction. Lot calculation formula

Losses per lot*/decrease factor;

Losses number of losing trades in a series, losses greater than one

For example, if value lots = 0.3, we calculate 0.3-0.3*2/3 = 0.1. Accordingly, the next trade after the losing one will open with a lot of 0.1.

Moving Period (default 12) – the period for which the moving average is calculated.

Moving Shift (default 6) – moving average shift in relation to price.

The following settings are on the General tab:

 Moving Average Trading Expert Advisor

Set the value of the position at which trades will be opened by the EA. And of course, if you want it to trade automatically, enable the “Allow the adviser to trade” parameter.

How does the Moving Average Expert Advisor work?

If the trade is successful, then deals are opened with the maximum lot (set in the Lots parameter). If suddenly there is a losing one, then subsequent deals are opened with a reduced lot (based on the value of Decrease Factor).

And the adviser works with such a lot until a positive deal closes. When this happens, the lot is restored, and trading goes on at the maximum lot until the next negative deal.

You can disable the decrease factor by setting the value to zero.

Regarding the opening and closing of deals by the adviser:

The EA checks the actual crossing of the moving average by the price. If this happens, then:

A deal is opened for buying if the price crosses the moving average from the bottom up; it closes when it crosses from the top down.

A deal is opened for sale if the price crosses the moving average from top to bottom; it closes when it crosses from bottom to top.

Let’s see some examples of opening sell deals. I set the display of the price chart on the line:

Moving Average

The line in blue is the moving average with a period of 12.

The line in red is the price.

As you can see, the Moving Average Expert Advisor is simple. It is ideal for beginner traders who are just starting to get acquainted with Expert Advisors. To move on to the complex, you must start with the simple! Join our Telegram channel for market updates

About the Author

Doyin Joye is a Trade Analyst specializing in Forex and global markets, providing clear, data-driven insights for confident trading. A lover of dough and lifelong learning, they stay disciplined, accountable, and constantly expand their knowledge through reading.

View Articles