Sample Strategy: Mean Reversion

Kush Jain
Mudrex
Published in
3 min readFeb 19, 2019

In our previous article, we built mean reversion auto-trading strategy on Mudrex using the simple ‘Price’ block. Lets us try and improve the strategy now.

Hypothesis:

What goes up must come down. Reversion to the mean is one of the most fundamental properties of markets. As a result, let’s try and create a strategy that looks at a short period average and compares it with a long period average and takes decisions on it.

We can use the Exponential Moving Average (EMA) indicator for this.

Exponential Moving Average: EMA is similar to Simple Moving Average (SMA), with the difference that EMA gives more wight, or importance, to recent price data points. Hence EMA can catch recent market movement better than SMA.

‘EMA (x)’ notation is used to specify EMA calculated for last ‘x’ days.

Image form fidelity.com

Strategy:

Buy when: The short-term EMA, EMA (9), crosses up the long-term EMA, EMA(26), signaling that recent prices are now getting closer to the long-term average and increasing

  • EMA(9) crosses up EMA(26)

Sell when: The short-term EMA, EMA (9), crosses down the long-term EMA, EMA(26) signaling that recent prices are now getting closer to the long-term average and decreasing

  • EMA(9) crosses down EMA(26)

Creating the strategy on Mudrex:

Navigate to top right menu on Mudrex screen and select ‘My Strategies’. On the new screen, select ‘Create Strategy’, which will navigate you to ‘Visual Strategy Builder’ page.

Components: To make this strategy all we need is 2 compare blocks as we are comparing 2 indicators, one each to buy and sell. Below is how the compare block for buy-call would look:

Final strategy visual: We would then go out and connect the compare blocks with the buy and sell blocks to complete our strategy.

We will also add a stop-loss and take profit to prevent losses.

Congratulations! You have now successfully created a new strategy.

Testing the strategy:

To test the ‘mean revision’ trading strategy on historical data, use ‘backtest’ feature. Backtesting a strategy is free on Mudrex :)

We will run 2 backtests on different markets.

  • Test #1: Running on ETH/BTC, 1H period from 1st Jan to 1st June gives a + 64.01% ROI
  • Test #2: Running on TRX/BTC, 1H period from 1st Jan to 1st June gives a -12.92% ROI

Links

A few quick references below:

Happy Trading!

Originally published at https://support.mudrex.com on February 19, 2019.

--

--