# The Centipede Moving Average Indicator

### Creating the Centipede Moving Average Indicator in Python

Moving averages have their benefits but also their limitations, with each type suffering from a specific bias be it lag or hyper responsiveness. There is generally not a solution to improve each type of moving average, but we can create a sort of scanner that send a signal when they are all giving the same bias. We will call this scanner, the Centipede.

Medium is a hub to interesting reads. I read a lot of articles before I decided to start writing. Consider joining Medium using my referral link (at **NO **additional cost to you).

**Join Medium with my referral link — Sofien Kaabar***As a Medium member, a portion of your membership fee goes to writers you read, and you get full access to every story…*kaabar-sofien.medium.com

### Refresher on Moving Averages

We are all aware of moving averages and their efficacy in trading. There are many types and everyone of us has a preferred type.

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.

Let us quickly list the main components of the Centipede. Note that all of the below moving averages have been discussed in previous articles which I encourage you to check out as the code would be too long to put in here therefore as a break of protocol, this article will be one of the rare code-free ones:

**Simple moving average:**This is the usual moving mean calculated as the ratio of the sum of the values to their quantity.**Exponential moving average:**This is a form of enhanced simple moving average where recent values are given more weight to account for the changes.**Smoothed moving average:**This is a more stable version of the exponential moving average and is directly related through it with a simple transformation.**Linear-weighted moving average:**This is a weight-adjusted moving average that gives the most recent value the highest weight and oldest value the lowest weight. It is a form of an exponential moving average.**Hull moving average:**This is a greatly enhanced version of the linear-weighted moving average.**Volatility-adjusted moving average:**This moving average takes into account standard deviation to accelerate and decelerate the calculation.**Adaptive moving average:**This is a highly adaptive type which includes some variables to account for a specific type of volatility.**Fractal adaptive moving average:**This is a highly complex moving average that uses the fractal dimension index as a component in the calculation.

Knowledge must be accessible to everyone. This is why, from now on, a purchase of either one of my new books *“ Contrarian Trading Strategies in Python” *or

*“*comes with free PDF copies of my first three books (Therefore, purchasing one of the new books gets you 4 books in total). The two new books listed above feature a lot of advanced indicators and strategies with a

**Trend Following Strategies in Python**”**GitHub**page. You can use the below link to purchase one of the two books (

*which one and make sure to include your*

**Please specify****Pay Kaabar using PayPal.Me***Go to paypal.me/sofienkaabar and type in the amount. Since it’s PayPal, it’s easy and secure. Don’t have a PayPal…*www.paypal.com

### Creating the Centipede

I believe it is clear by now that the Centipede is a trend-confirmation and regime detector where it is composed of many types of moving averages that contribute equally.

Before we see the indicator in action, let us discuss how will we use it:

**A confirmed bullish market**is identified whenever all the components of the Centipede are below the current market price.**A confirmed bearish market**is identified whenever all the components of the Centipede are above the current market price.

The next figure shows the indicator in action. Let us interpret what we see.

If we color code the chart according the following rules:

**If the Centipede equals 8, the bar is colored in green.****If the Centipede is greater than 4 but less than 8, the bar is colored in blue.****If the Centipede is less than 4 but greater than 0, the bar is colored in brown.****If the Centipede equals 0, the bar is colored in red.**

Whenever the Centipede is showing extreme values such as zero (Red) and eight (Green), we might fear from the fact that the market may be too overstretched.

Whenever we switch from green to blue, we can start thinking about a bearish move to come and whenever we switch from red to brown, we can start thinking about a bullish move to come.

If you want to see how to create all sorts of algorithms yourself, feel free to check out Lumiwealth. From algorithmic trading to blockchain and machine learning, they have *hands-on* detailed courses that I highly recommend.

**Learn Algorithmic Trading with Python Lumiwealth**

Learn how to create your own trading algorithms for stocks, options, crypto and more from the experts at Lumiwealth. Click to learn more

### Summary

To sum up, what I am trying to do is to simply contribute to the world of objective technical analysis which is promoting more transparent techniques and strategies that need to be back-tested before being implemented. This way, technical analysis will get rid of the bad reputation of being subjective and scientifically unfounded.

I recommend you always follow the the below steps whenever you come across a trading technique or strategy:

*Have a critical mindset and get rid of any emotions.**Back-test it using real life simulation and conditions.**If you find potential, try optimizing it and running a forward test.**Always include transaction costs and any slippage simulation in your tests.**Always include risk management and position sizing in your tests.*

Finally, even after making sure of the above, stay careful and monitor the strategy because market dynamics may shift and make the strategy unprofitable.