The ABCs of creating a mean reversion strategy – Part 2

This post is the continuation of the steps for creating a mean reversion strategy from the first part of The ABCs of creating a mean reversion strategy – Part 1. You can also listen to part 2 of my interview on Better System Trader here.

A quick recap of the topics covered in part 1. I covered trading universe, indicators to measure daily mean reversion, combining multiple mean reversion indicators, and last bar mean reversion.

Other Filters

Besides indicators filtering for a pullback, you can have other filters. I use the close above the 200-day moving average as signal of a healthy stock. Trading below the 200-day moving average works but comes with additionally volatility and much bigger losers.

Two more filters I use are 10-day ADX and 100-day Historical Volatility.  These can be used in two ways. Filtering for values above 40 or values below 40. This depends if I am looking for volatile stocks or trying to avoid them. Avoiding them reduces drawdowns but also reduces returns.

Typically, I try to limit a strategy to two mean reversion indicators and three other indicators.


Market Regimes

Creating a strategy that works in all types of markets is difficult. Two methods for a regime filter are moving average based and volatility based.

Moving average: Using the 200-day moving average of the S&P500 index to define our regimes as bull when the market is above it and bear when it is below it is a good method.

Volatility based: Here you can use the 100-day historical volatility of the S&P500 index and then use a cut off value. When above this value, the market is in high volatility environment and when it is below it is in a low volatility environment. We can also use the VIX to determine the regime. There are many other ways to measure the market volatility.

You can also combine the two above to create multiple regimes. You need to be careful about creating too many regimes because some may not have very many trading days.

Once you have your regime, for example using 200-day MA, then you must decide what to do in each regime. For a bull market, this is when the strategy trades normally. For a bear market, the strategy can go 100% in cash, or reduce position size by 50% or trade different values for your filters such that your rules are more stringent.


Ranking of signals

When the strategy has more signals than it can trade, how do you rank them? For mean reversion, the two best rankings I have found are 100-day Historical Volatility (ranking from high to low) and Rate of Return (3,5,7 day) ranking from most sold off to least. Other methods that work are using the mean reversion indicator from the buy rule. For example, if the strategy uses RSI2 as an entry then we use RSI2 to rank the signals from low to high. How you rank can have a large impact on your results but people rarely spend much time deciding this.


Position Sizing

Now that we have a signal, how much capital does the strategy allocate per trade? Two common methods are fixed percentage and volatility based. My preferred method is allocating the same percentage per position. Through all my testing, trying different types of position sizing has rarely had much change in the results and definitely not enough on the positive side to justify the additional complexity. At the end of the day, I prefer simpler rules.

Now given that, some people will prefer to use volatility based sizing. This is where the volatility of the stock is used to adjust the position sizing. Where more volatile stocks are allocated less capital than less volatile stocks. For some people this makes more sense to do this way. You want to have rules that will make it likely you will follow your strategy. Even if that rules complicates the strategy or lessens the results.


Risk per trade

For mean reversion strategies, they rarely have a stop which makes this calculation difficult. I control my risk by the amount allocated to the strategy and the percent per position. I then ask myself, what would I do if I woke up one morning and a stock I owned opened down 50%. If that would cause me to break my rules, then I have too much allocated. If you are trading smaller cap stocks, I can guarantee you this will happen to you.


Number of positions

This particular strategy rule is rarely discussed. This is more important when using fixed percentage sizing. How many positions will the strategy take? Five positions at 20% allocation each? Twenty positions at 5% allocation each? With less positions, the strategy is subject more to luck, both good and bad. Meaning one good luck trade can have a large positive impact on the results. Of course, one bad luck trade can have a large negative impact on the results. When doing an optimization run (between 5 and 20 max positions), you will notice that the 5 positions runs will tend to show up more having the highest CAR but they will also show up more having the lowest CAR. The highest CAR benefited from good luck while the low ones from bad luck. I tend to go with 10 positions with 10% allocation. I will go with 5 positions with 20% allocation if I am trading bigger cap stocks.



There are two basic ways of entering the signal. At the open or at a limit price below the previous day’s close. Entering at the open has the benefit of knowing you will enter the trade. But this type of entry tends to have smaller returns than entering on a limit.

With a limit entry below the previous day’s close, you want the stock to continue the sell off a little more. These entries produce bigger winners but at a cost of not getting filled often. I find that low volatility environments like we have now make this type of entry hard to trade because fills become a lot less frequent.

For balance, I trade both methods.



Should you add to your position? One approach that I have research extensively is waiting for a close below your entry price. While scaling-in may greatly improve your % winners it comes at a cost of reducing your returns. For me it is not worth it. But if you must have a high % winners in your strategy, I strongly suggest you look at scaling-in.



Now that the strategy is in a position. How is it going to exit? Some combination of the below will produce a good exit strategy.


Indicator based: This exit by itself will give the best returns. I will use the same indicator that measured the mean reversion to get out of the position. If I used RSI2 under 10 to get in, I would then use RSI2 over 50 to get out. Sometimes I will use a different mean reversion indicator to get out. If I used RSI2 to get in, I can also use a close above the 5 day moving average to get out. In general waiting for the stock to bounce produces the best results. The problem is sometimes it takes a very long time to bounce. It is hard to hold onto a stock that is going down day after day.

Maximum stop loss: I have written before about using this type of exit on this post, Maximum Loss Stops: Do you really need them?. On the rare occasion that I use this type of stop, it tends to be quite large at around 20 to 25%. The main reason to use this stop is that it psychologically helps you trade the strategy.

Trailing stop: I have never managed to get this type of stop to work. Meaning when I try adding this to a strategy it greatly reduces returns and make drawdowns worse.

Scaling out: Scaling-out is selling part of your position when the stock bounces and then either having a trailing stop or waiting for it to become overbought for exiting the rest of the position. For example, sell half the position on RSI2 above 30 and then the other half when RSI2 is above 70. I really like this idea but like other good ideas, I could not produce good results from it. I have tried both using intraday exit and end of days.

Profit target: Using a profit target on mean reversion trades simply cuts your profit. Letting the bounce fully happen is best. Again, another idea that I have not had success with.

Bar based: On a bar based exit, the trade is exited after being in it for X trading days. Since most winning mean reversion trades exit by 7-10 days, this tends to be a good value to use. This is one of my favorite non-standard exits to use. Even though this will reduce returns slightly, the psychological benefit of not being in a trade that goes down day after day for a several weeks is worth it for me. If you have not tried this type of exit before, I highly recommend it.

For my strategies, I typically will use an indicator exit and a bar exit combined. Even though, I have not had success with trailing stops, scaling out and profit targets, if using these exits gives you the psychological advantage of sticking to your strategy then think about using them.


Final Thoughts,

Even though I gave no specific rules, you should be able to build your mean reversion strategy using the steps outlined in this post and the previous one. Most these steps are necessary for any strategy. But what works or does not work for a mean reversion strategy may not work for another type of strategy like breakouts or trend following.

On this post, Simple ConnorsRSI Strategy on S&P500 Stocks, you can see most of the ideas discussed being applied to a strategy.


Backtesting platform used: AmiBroker. Data provider: Norgate Data

Good quant trading,

Click Here to Leave a Comment Below

Robert - November 1, 2017 Reply

Hello Cesar,

Thank you for the good interviews with Andrew (one more to go!). I got the impression that your RTM trades are all (or mostly) long trades; true? If not true, can you estimate what proportion of your RTM trades are long vs. short? Again, thank you.

    Cesar Alvarez - November 1, 2017 Reply

    Currently I trade two long RTM strategies on stocks and one short RTM strategy on ETFs. Given how strong the market is, I would say about 90% of my trades are long

Thomas Musselman - November 1, 2017 Reply

Is the inclusion of 100-day Historical Volatility (ranking from high to low) the volatility of the overall market regime or the stocks you are selecting, or both?

Is it the same as the 100 day beta?

    Cesar Alvarez - November 1, 2017 Reply

    I tend to us HV100 for both. The formula for HV is standard deviation of daily returns over the last 100 days times the square root of 252 times 100.

Hardik Upadhyay - November 1, 2017 Reply

Hi Cesar,

Have you tested any mean reverting strategy with rankings like HV100 ? If yes, what has been your experience of ranked system versus non ranked system ? As I see it, once your rank signals in terms of say HV100, then the number of trades must reduce. Can you share your thoughts here ??


    Cesar Alvarez - November 2, 2017 Reply

    I use HV100 for ranking all the time. Ranking is needed when you have too many signals for your available cash. Say you buy 10% per position, 100% in cash and you have 50 signals? Which do you take? Make sense?

Ola - November 2, 2017 Reply

Hi Cesar,

What is your experience backtesting entries using limit orders? Any advice?

    Cesar Alvarez - November 2, 2017 Reply

    Lots of experience testing with limit orders. Not sure what you mean for ‘advice.’ In backtesting or results or trading or??? Can you clarify?

Craig Peters - November 2, 2017 Reply

Hi Cesar

Great blog posts and interviews with Andrew. Have you considered using market internals (market breadth, e.g. Advance/Declines) as a filter for your mean reversion trades on stocks?
I trade trend-following/momentum strategies only. But I’ve had some success in backtesting and in live trading in applying a daily Advance/Decline filter on my breakout setups on stocks, and this could theoretically work in reverse for mean reversion setups.
It filters out short breakout setups when after a day of significantly more declines occurred than advances (i.e. yesterday was a bad day for the market as a whole).
Filtering out short setups in scenario, counter-intuitively, reduced the number of fake short trade breakouts by a significant margin. Approximately by 33% in my backtesting.
In theory, it would follow that long mean-reversion setups should do well in this scenario, or at least experience a higher win rate.


    Cesar Alvarez - November 2, 2017 Reply

    I have not tried a much in terms of using market internals. If you are interested in seeing a blog post on this and have some specific ideas, use the Contact Me, to send your ideas to me. If they look testable, then I could write about it.

Ryan - November 5, 2017 Reply

Cesar, much of what you discuss is based on testing US equities and indices. What has been your experience with non-equity related markets and their respective mean reverting tendencies e.g. grains, metals, softs, FX, rates etc.? Which markets test well given your outline on mean reversion part I & II?


    Cesar Alvarez - November 5, 2017 Reply

    I don’t trade the futures or FX markets. From working with clients, they have had success using MR on futures markets.

Andy - December 17, 2017 Reply

Thanks Cesar for a great posting and also very interesting series of podcasts on this subject. I believe you mentioned trading Russell 3000 stocks. Do you use Norgate data for this and if so how do you account for delisted stocks in your backtests (ie avoid survivorship bias by using only the historic index constituents)?

    Cesar Alvarez - December 17, 2017 Reply

    I am in Norgate’s beta program which has historical constituent data for the index. So this avoids pre-inclusion bias. Unfortunately, the program is currently closed to new people. I believe they will be offering this data early next year to subscribers. I would email them to find out their time table.

Lu - December 22, 2017 Reply

Hi Cesar! Thanks for Your posts. Do You consider any particular ratio between the filter and the oscillator relevant for a good strategy outcome?

QFund - January 20, 2018 Reply

“Trailing stop: I have never managed to get this type of stop to work. Meaning when I try adding this to a strategy it greatly reduces returns and make draw-downs worse.”

So true and I totally agree! I am glad you point this out, I always wonder why this particular type of stop almost reduces performance every time I use it. I prefer ATR based stops.

Leave a Reply: