Moving Average Zone Strategy

A Reactionary Technical Trading Strategy in Python

Sofien Kaabar, CFA

--

Contrarian trading can also be done through moving averages whenever the market approaches them. This is another way of finding dynamic support and resistance levels. Understanding market mechanics is extremely important in knowing which moving average to choose.

I have released a new book after the success of my previous one “Trend Following Strategies in Python”. It features advanced contrarian indicators and strategies with a GitHub page dedicated to the continuously updated code. If you feel that this interests you, feel free to visit the below Amazon link (which contains a sample), or if you prefer to buy the PDF version, you could check the link at the end of the article.

The Concept of Moving Averages

Moving averages help us confirm and ride the trend. They are the most known technical indicator and this is because of their simplicity and their proven track record of adding value to the analyses. We can use them to find support and resistance levels, stops and targets, and to understand the underlying trend. This versatility makes them an indispensable tool in our trading arsenal.

EURUSD hourly values with its 55-period Simple Moving Average.

As the name suggests, this is your plain simple mean that is used everywhere in statistics and basically any other part in our lives. It is simply the total values of the observations divided by the number of observations. Mathematically speaking, it can be written down as:

To code the simple moving average, we can follow this syntax (only for arrays) in Python while making sure we have defined the primal manipulation functions also seen below:

def add_column(data, times):

for i in range(1, times + 1):

new = np.zeros((len(data), 1), dtype = float)

data = np.append(data…

--

--