Adaptive Trend Following Trading Strategy based on Renko

  1. Concept
  2. Algorithm description
  3. Trading strategy development
  4. Backtesting and analyzing the result
  5. Further problems discussion
  6. Conclusions

Concept

Financial time-series have a high level of noise in data. Would be good to have an ability to reduce a noise. In this article it is proposed to use Renko brick size optimization. The key idea of the approach is to quantify the quality of a Renko chart and try to get an optimal brick size for using in a trading. If you are not familiar with the Renko charts will be better follow the link of the article.

Algorithm description

This trading strategy is a typical trend following, but the following based on the last Renko direction, not the price of moving average. The basic steps are:

  1. If the Renko chart is empty then build the chart using brick size optimization. Adaptivity implies that volatility level could be important for optimizing of the process. In this example, the optimal brick size is inside of IQR of absolute price changes (e.g. daily) for the last N days. Also, you can choose any range for optimization (based on ATR indicator, fixed, or percentage of the last price).
IQR explanation

Trading strategy development

I will use Catalyst framework for developing the trading strategy. How to install the framework and a few examples you can find on the website.

Backtesting and analyzing the result

Let’s run our script in Catalyst environment by command:

Terminal window after launching the script
Result graphs in Catalyst
Equities
Algorithm returns
Summary stats
Drawdown
Top-5 drawdown periods
Top-5 drawdown periods table
Distribution of monthly returns
Box-plots of returns
Moving average of volatility
Moving average of Sharpe ratio

Further problems discussion

Creating a reliable algorithmic trading strategy is a difficult process that includes different steps. The general trading idea is necessary, but not sufficient condition. I suggest to think about these problems to get stable and reliable strategy:

  1. Attempt to use minute data resolution to take into consideration data that we get intraday. Now the algorithm uses daily resolution only, it means that we lose data and price movements.
  2. Change market orders to limit orders. This will allow to reduce commissions, because taker commission is higher than maker commission. Some exchanges even pay to you for limit orders, it calls a rebate, this is kind of a reward.
  3. Carry out a lot of experiments with different assets to create a reliable portfolio of assets and tune a money-management between them.
  4. Develop and follow the re-optimization — forwarding rule to get the moment when we should change some parameters of the model (length of history, cover ratio, timeframe, and etc.). This rule includes frequency of optimization, time periods for optimization and forwarding (or walk-forwarding) processes, minimal requirements of metrics to accept the algorithm as working.
  5. Develop or choose the execution framework to run the algorithm in the production mode. Even if you can get a reliable trading strategy that approved on tons backtests you can fail in a real mode, because you will get a lot of errors or imperfections in an infrastructure (inside or outside of your ecosystem). For example, you can use Catalyst in backtesting mode, but you can’t use it in production for this algorithm, because Catalyst doesn’t support trading on margin account now.

Conclusions

  1. Created the algorithmic trading strategy based on theoretical research. This algorithm tries to adapt to a volatility level, reduce a noise, and follow the trend.
  2. The algorithm has a positive result. Demonstrated the different metrics and graphs of performance.
  3. Suggested an advice on how to improve this research.
  4. Source code you can get on github (catalyst script and ipython-notebook for advanced analytics).

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store