top of page
  • nikhilshenai

An Example — The Moving Average Crossover Strategy (Part 1 of 2)

Updated: May 9


Hello and welcome to our fifth article. This issue explains the trading process with reference to a basic trading strategy, the Moving Average Crossover strategy (for background detail, see the entry at babypips). All articles are saved at our Medium page.

Our software plugin for MT4, Advantage, has progressed to Beta! With it you can code and execute MQL4 strategies 4x faster. Sign up for Advantage at the following link today and you will get free access until the end of 2022:

These articles are based on my experience from consulting and product development at The IQT. Do let us know if there are topics you would like us to cover, questions you would like to resolve, or if there are insights you would like to share from your own experience.

Last Time

In Article 4 — “A Detailed Look at The Trading Process”, we discussed the different stages involved in the trading process, i.e. Analysis → Setup → Entry → Management → Exit.


The most basic form of the Moving Average Crossover strategy does not feature a management stage i.e. it looks like: i.e. Analysis → Setup → Entry → Exit;

1. Analysis: Usage of Moving Averages to identify short term and long term trends

2. Setup: Determination of upward and downward crossovers

3. Entry: Buy on an upward crossover, sell on a downward crossover

4. Exit: Close a buy on a downward crossover, close a sell on an upward crossover

We will review the missing stage — Management — in the next article.

Main Points

A more detailed explanation of the above stages follows.

1. Analysis

Moving Averages (MAs) are used in Technical Analysis to determine price trends (for more detail, see Investopedia). A short-term MA crossing a long-term MA (a crossover) can be interpreted as the beginning of a new trend.

A trader’s analysis identifies the type of MA to be used e.g. Simple vs Exponential, and the optimal lengths of the window lengths used for the short-term and long-term MA. E.g. through backtesting the MA Crossover strategy and optimising its parameters, we might conclude that Exponential MAs are preferable because they place more importance on the recent past, and the optimal short-term MA length is 5 days, while the optimal long-term MA length is 50 days.

Analysis may also identify general account management parameters, such as how much we stake per trade, and the maximum number of concurrent trades. E.g. we might risk 0.1% of the account per trade, and only enter 1 trade at a time.

2. Setup

Setup involves the real-time calculation of the MA values and the determination of whether signals to enter or exit a buy or sell order have occurred in the latest time period.

Summary diagrams of entering and exiting orders are below. The left-hand diagram is for a buy order, and the right-hand diagram is for a sell order.

Entering and Exiting a Buy Order (left) and a Sell Order (right)

a) Buy Signal: Upward Crossover (“Golden Cross”): the short-term MA (dark blue line in the left-hand diagram) rises above the long-term MA (light blue line), signifying a buy trend.

b) Sell Signal: Downward Crossover (“Death Cross”): the short-term MA (dark blue line in the right-hand diagram) falls below the long-term MA (light blue line), signifying a sell trend.

3. Entry

We enter a new trade according to the signal being identified in the Setup stage, e.g. if a buy signal was identified, we enter a new buy order. This is marked by the first blue arrow in the left-hand diagram.

The decision to enter the trade may depend on our account management conditions, e.g. if we already had an active trade, in order to avoid having more than 1 active trade at the same time, we might not enter the buy order.

4. Exit

For the MA Crossover strategy, the standard exit signal is simply the opposite of the entry signal. E.g. if we have an active buy order, then we close it if a sell signal / downward crossover occurs in the market. This is marked by the second blue arrow in the left-hand diagram.

Further exit conditions might be defined via stoplosses and takeprofits;

Stoploss: a price level set to limit our maximum loss. If the price goes beyond this, the trade is automatically exited.

Takeprofit: a price level set to capture a certain amount of profit. If the price goes beyond this, the trade is automatically exited.

Stoplosses and takeprofits can be set either technically, e.g. using MA calculations, or via other considerations, e.g. to guarantee a fixed amount of loss or profit such as 0.1% of the account.

Further Reading

We will review forms of trade management in the next part — “An Example — The Moving Average Crossover Strategy (Part 2 of 2)”.

Thanks and happy trading!

6 views0 comments


bottom of page