Today’s topic is on finding the optimal periodicity for the RSI indicator and the techniques should apply to other sorts of indicators as well. The good news is that it won’t require any rocket science.

John Ehlers has written a lot about this topic, and his articles spurred my interest in the topic, which frankly I had never considered. I might should note now that I have not reviewed the actual methodology that Ehlers used in any depth but my impression was that the methods were very advanced. But, I realized I could tackle this problem using just basic statistics.

Before we start analyzing specific solutions, I want to take a moment to describe what we are actually attempting to do. The question that we are trying to answer is how do we find the optimal length to use when calculating an indicator. A poor length value may result in the RSI spending too much time in either the overbought or oversold states or failing to reach the proper levels. Obviously, the optimal look back will change as market conditions change and therefore our methods should be adaptive and responsive to the market.

The goal is to find a metric to rank how well behaved the RSI is. A well behaved RSI is one that spends about an equal amount of time in overbought and oversold levels. During a trending market, if the RSI gets stuck into overbought conditions then that would be an example of a poorly behaved RSI. The solution thus is simply to measure the amount of time that the RSI spends in overbought and oversold conditions. My original inspiration came from the idea of a histogram. We simply add 1 for every bar that the RSI is above our threshold and subtract 1 for every bar that the RSI is below our threshold. The absolute value of the resulting summation is our error metric, which we seek to minimize.

**Key Concept:** Sum the amount of time that the RSI spends above 50 and below 50 and take the difference. The absolute value of the difference is our error metric, which we seek to minimize.

Next, we will simply compute our error metric for every RSI length in our search space, and select the RSI with the minimum error. In this example, I searched from RSI(2) to RSI(14). There is one more consideration which is determining our lookback. Too short a lookback will lack statistical relevance while too long a lookback will defeat the benefits of adaptation. Some manual trial and error was used before I settled on a lookback of 90 days.

We conducted the test using the S&P 500 Emini and have selected the long only RSI(2) with standard 30/70 overbought/sold thresholds as our baseline. The results are below:

@ES Daily 1/1/2004-1/29/2017 | ||
---|---|---|

RSI(2) Simple | RSI(2..14) 50/50 | |

Net Profit | $86,075.00 | $82,812.50 |

Max DD: | ($16,937.50) | ($17,887.50) |

Profit Factor: | 1.84 | 1.98 |

Avg Profit Per Trade: | $304.15 | $363.21 |

Number of Trades | 283 | 228 |

Win Percentage | 74.91 | 75 |

While the results are not too different, we do see our profit factor and average profit per trade has improved. The net profit is slightly reduced and the drawdown slightly higher but essentially similar.

We can get better results by making our threshold more restrictive. Instead of using the median line, we can use the amount of time that our indicator spends in actual overbought and oversold levels. This makes some sense as the overbought/sold conditions are what’s really important. We use the same technique but now we try to balance the amount of time we spend below 30 and above 70. We see significantly better results. The results improve even more when we try to balance the extreme overbought/oversold conditions using 20/80 as our thresholds: notice we do not change our actual buy/sell conditions.

@ES Daily 1/1/2004-1/29/2017 | ||
---|---|---|

RSI(2..14) 30/70 | RSI(2..14) 20/80 | |

Net Profit | $73,387.00 | $83,375.00 |

Max DD: | ($16,937.50) | ($16,937.50) |

Profit Factor: | 2.53 | 2.54 |

Avg Profit Per Trade: | $824.59 | $850.77 |

Number of Trades | 89 | 98 |

Win Percentage | 74.16 | 77.55 |

Both the 30/70 and 20/80 optimization thresholds show significant improvement in the profit per trade over the baseline, fewer trades, and higher profit factor. This suggests that our RSI optimizations are improving trade quality significantly and suggest our indicators are better synchronized to the more dominant cyclical structure of the market. While the net profits are not quite as strong, the strong increase in average profit per trade is especially appealing.

It appears we can find significant cyclical structure in the markets using simple statistical techniques. However, we did have to use some trial and error in determining the lookback to calculate our statistics over, and that may be one area for improvement.

Curtis is passionate about markets. He has developed top ranked futures strategies. His core focus is (1) applying machine learning and developing systematic strategies, and (2) solving the toughest problems of discretionary trading by applying quantitative tools, machine learning, and performance discipline. You can contact him at curtis@beyondbacktesting.com.

**Session expired**

Please log in again. The login page will open in a new tab. After logging in you can close it and return to this page.

[…] –from blog Beyongbacktesting […]