Charting a way through price prediction... reversion to the mean

James, 29th June 2020

Candlestick trading chart

Volume 1: Rules based trading models

Technical analysis and charting techniques are used by traders to help them place better trades with a higher probability of success. Models are back tested on past price data, and strategies that worked well on the past data are used on the live price data to help decide when to buy and when to sell.

Many of us may be aware of the terms algorithmic trading, and high frequency trading. This is an example of automated trading, however the trading does not have to take place on such a short timescale, in fact trading over longer term time scales can also be automated. The advantage of automating trading decisions is that it helps take the emotion out of trading, and to standardise the decision making.

The arsenal of computational techniques available for assisting trading decisions is growing, and so is the data available. Good modelling starts with good questions and clear objectives. Here the objective is to make good returns trading Ethereum on a trade time scale of weeks to months. We will look at a simple trading model that seeks to do that, and use it to demonstrate key concepts in technical analysis and charting.

The model uses moving averages to help assess if the market is rising or falling. It also employs the concept of reversion to the mean to decide when to place trades. So what is meant by mean reversion? We can use the graph below to help explain it.

If we look at the price data for Ethereum for late 2017 early 2018 we can see several things. Firstly the price is very volatile, there were good opportunities to make both large gains on a trade, and also large losses The mean is the average price, moving averages on two different timescales (50 day and 100 day) are plotted. Looking at the 100 day simple moving average (SMA) you can see that the price trend is generally rising. However the price keeps falling back to near the 50 day SMA (mean reversion) and eventually to the 100 day SMA. Mean reversion is the idea that the price doesn't stay above its average price.

It sounds simple, you need to buy low and sell high, but it's actually not that simple. The first question you have to answer is, "is the price right now comparatively low or comparatively high?". The second question you have to answer is, "where is the price more likely to go from here up or down?". The charting techniques and concepts like mean reversion help to answer those questions, and pick times to trade where both questions are easier to answer.

Looking at the price over a much longer timescale (2016 to March 2020), you can see there are both rising and falling means (bear markets and bull markets). Devising rules based on the concept of reverting to the mean over this longer timescale is a bit more challenging. By looking at the graphs some example rules that might give good trades have been made, and using a model we can test them and seek to improve on them.

Rule 1 Buy only if price < 100 day SMA and remained below for > 5 days Identifies a probable market low
Rule 2 Buy if rule 1 satisfied, buy when price above 100 day SMA and stays above for more than 10 days, but not if the gradient 100 day SMA is less than - 0.5 $/day Identifies a probable rising market
Rule 3 Sell if the close price fall below the 50 day SMA Identifies a market peak has passed

The rules produce a reasonably successful trading model, a model that is able to take a starting balance of $5000 in 2016 and trade it up to $77915 by March 2020.

Date Trading action Ethereum close price Balance Ethereum Balance USD
27-05-2016 None 11.25 0 5000
25-09-2016 Buy 13.07 381.79 0
10-10-2016 Sell 11.78 0 4487.49
26-01-2017 Buy 10.66 420.03 0
15-07-2017 Sell 167.72 0 70436.97
02-10-2017 Buy 296.72 237.35 0
01-11-2017 Sell 290.82 0 69016.60
26-02-2019 Buy 135.76 508.3 0
14-07-2019 Sell 225.76 0 114743.45
26-02-2019 Buy 162.40 706.50 0
12-03-2020 Sell 110.30 0 77915.49

Not every trade the model makes is profit making, but the overall gains are pretty good ~1460% growth. The trading model could be improved by getting it to sell closer to the price peaks. The current model sells after peak based on the 50 day SMA, the question that arises is as follows "is there a better way of identifying and selling closer to a market peak?".

An improved model using Momentum (MTM) and Rate of Change (ROC) was developed, in order to improve the timing of sell orders, so that sell orders are place closer to the price peaks. The trades from this model are shown below:

Date Trading action Ethereum close price Balance Ethereum Balance USD
27-05-2016 None 11.25 0 5000
25-09-2016 Buy 13.07 381.79 0
12-03-2017 Sell 23.39 0 8920.08
26-07-2017 Buy 203.23 43.84 0
12-01-2018 Sell 1260.00 0 55231.33
26-02-2019 Buy 135.76 406.76 0
28-02-2020 Sell 227.37 0 92474.35

With the improved model fewer trades are placed, an artefact of sell orders being placed at different dates, and the buy rules not being met as often. The model places sell orders much closer to the market peaks and in spite of fewer trades overall returns are significantly higher. A starting balance of $5000 in 2016 is traded up to $92474 buy March 2020. This represents gains of ~1749%.

Both of the models trade on a low frequency time scale (weeks to months). The type of model demonstrated here would be called a "rules based expert system" in AI terminology. It is a basic model (rules based expert systems date back to the 1970s), and requires "an expert" to develop the rules, and the rules have to be manually programmed. More modern and sophisticated AI techniques such as Machine Learning (ML) can be used to develop the rules on their own, and code it themselves.

This is a start of the journey, in the next volume we will look at how to improve and optimise these rules based models using a Genetic Algorithm, and add trading on shorter time scales to increase gains in the rising markets. We hope you join us for the next segment (TA volume 2). In later segments we will also look at ML techniques such as SVMs and other AI techniques like clustering to enrich the modelling arsenal.

If you want to take a deeper look at how the trading models presented here in volume 1 were developed, and also a deeper look at the numbers, please have a look at our deep dive paper. It provides some valuable additional insights!

Link to deep dive model article: "Evolving Money charting a way through price prediction: Rules Based Trading Models - TA volume 1"


DISCLAIMER: Technical analysis techniques seek to improve the probability of making good trades in the future based on using past data, and making the assumption that in the future behaviours from the past will be repeated. There are no guarantees, as the future is unwritten. Different circumstances can come into effect that mean past behaviours are not repeated; behaviour also changes over time. The ideas presented in this blog should not be construed as investment advice.

bank cards
Suited man watering a money tree