September 30, 2020

Using strength to exit a mean reversion trade

I had a long-time reader, Cristian Franchi, send me a mean-reversion strategy that he wanted me to test and write about.  What caught my attention was the rules differing from what I typically see and use. Different ways of measuring strength of a sell-off and volatility expansion. Along with a different type of exit being used on a mean reversion strategy. Not simply waiting for the bounce.

Rules

Test date range 2007 to 8/31/2020.

Buy

  1. Stock is a member of the S&P500 index
  2. 4-period RSI is less than 30
  3. The highest High in the last 21 days divided by the lowest Low of the last 21 days is greater than 1.04
  4. The r-squared value of the last 4 days is greater than .6
  5. The 4-day standard deviation of closes is greater than the 16-day standard deviation of closes time .3
  6. 126-day return of SPX is greater than zero

Rank stocks from lowest 100-day historical volatility to highest. Buy on the next open.

Rule (B) is looking for a sell-off.

Rule (C) is looking for stocks that have a large enough trading range in the last 21 days

Rule (D) is looking that the short-term sell off is clearly going down. This is an interesting way of checking for that I have not done before

Rule (E) is looking for volatility expansion. A different way than I would typically do

 

Sell

  1. Stock’s 4 period RSI closes above 65 for 5 or more days
  2. If still in position after 30 trading days

Exit on the next open.

 

The RSI Exit

I like the idea of the RSI exit. It is looking for a couple days of strength before getting out. Not just a bounce. A long time ago I tried similar ideas without much success.

Of course, I think are these optimized values? Are there better values? We will see later in the post.

Results

Not what I would call tradeable results.

 

Optimizing

Whenever I get a strategy, I want to know are the parameters that I was given overfit? What happens when I optimize them? What I really cared about was the exit, not the entry rules. So, my focus will be on those.

Optimization values:

  • Stock’s 4 period RSI closes above [50, 55, 60, 65, 70] for [2, 3, 4, 5, 6, 7, 8] or more days
  • If still in position after [20, 30, 40, 50, 60] trading days

Here are the top 5 results.

A big improvement but still not in the I would trade it level. Holding the position longer helped.

 

Nasdaq 100 Index

What if we trade stocks in the NDX?

A slight improvement but again not enough.

Spreadsheet

Fill in the form below to get the spreadsheet with lots of additional information. See the results of all variations from the optimization run. This includes top drawdowns, trade statistics and more.

Final Thoughts

Even though this did not yield results good enough to trade, I did like the concept and execution of the exit. I must remember this when testing other strategies. It might be a good exit to use for a longer term strategy to tell when a stock has become over extended. For example, exit when RSI4 is greater than 90 for 5 days.

Backtesting platform used: AmiBroker. Data provider: Norgate Data (referral link)

Good quant trading,

Fill in for free spreadsheet:

spreadsheeticon

 
Visited 342 times, 1 visit(s) today

Click Here to Leave a Comment Below

Tatiana - October 2, 2020 Reply

Hi, I follow and appreciate your work, thank you very much!
I tried to match your results, but I got 2x DD and less return. I use premium Norgate data and amibroker CBT. I suspect mistakes are somewhere in my strategy rules:
RSI(4) 1.04 AND
Correlation(Cum( 1 ), C, 4) ^ 2 > 0.6 AND
StDev(C, 4) > StDev(C, 16) * 0.3 AND
ROC(Foreign(“$SPX”, “C”), 126) > 0
Do you see any mistakes there? Also I couldn’t find how many maximum positions your are holding.

    Cesar Alvarez - October 2, 2020 Reply

    Are you using historical constituent data?
    It looks like you are missing some code
    RSI(4) < 30 and HHV(H,21)/LLV(L,21) > 1.04

    A max of 10 positions, equally weighted.

Tatiana - October 4, 2020 Reply

Sorry, it was wrong typing, so I didn’t miss that code. Yes, I use index constituents filter.
Could it be that I calculate R-Squared wrong:
Correlation(Cum( 1 ), C, 4) ^ 2 > 0.6?
Or maybe you don’t allow reenter stocks that had exited on “30 day”?
Do you exit stocks next Open as well as entry?
Thank you very much

Leave a Reply: