Machine Learning in Trading: Using Heiken-Ashi returns as inputs

Most of the machine learning systems that I have showcased on this blog have so far constructed training examples using simple or logarithmic bar returns as inputs. Up to this point the simple returns have proved to be a powerful predictor for many different types of outputs – including the trade outcome outputs we now use most commonly – making them a very important tool in the creation of machine learning based systems. On today’s post I want to introduce the use of Heiken-Ashi based bar returns as inputs which serve as a way to expand on the performance and possibilities of machine learning strategies. We will see why these are different from the traditional simple return inputs and what advantages they may offer against the strategies I have previously showed on this blog.

Certainly there are many alternatives to simple bar returns ((open[n] – open[n+1]) /open[n+1]) that we may consider for the building of examples for training machine learning algorithms. Last year I showed you some examples using the RSI and CCI indicators to do this and we saw some of the different advantages and disadvantages that come from using these inputs. However there are other types of inputs that are similar to simple bar returns, different from indicators in that they do not use many different bars for their calculation, which we might use to build these examples. From the possibilities available the Heiken-Ashi bar structures are particularly interesting since they represent a modification of the traditional OHLC structure that summarizes the information from the OHLC into single points.

Of particular usefulness is to consider the Heiken-Ashi (HA) candle closes which can be calculated as the average of the open, high, low and close prices for a bar and which we can use to establish a Heiken-Ashi return of the form (HAC[n] – HAC[n+1]) /HAC[n+1] where HAC is the Heiken-Ashi Close, n represents the shift of the last closed bar and n+1 represents the shift of the second last closed bar in the past.  This HA based return has several advantages compared with the traditional simple bar returns, mainly that it contains information from high, low and close information which is fundamentally missing from the calculation of the simple return which only takes into account open prices. In this manner news spikes and week-end gaps are indeed accounted for by the HA returns – which may be important for predictions – while the simple returns basically ignore this information.

On the first image above you can see a sample machine learning system derived from the EUR/USD using this new inputs using a neural network algorithm. The system trades and retrains on hour 8 GMT +1/+2, uses 155 example when retraining and uses the past two HA returns as inputs. The outputs are the outcomes of trades that are evolved using square root function with a break-even period of 15, an initial stop of 120% of the 20 period ATR and a maximum frontier of 170 bars. It is also worth noting that this example does not constitute the maximum possible gains from the use of HA returns as inputs, it is merely a sample to demonstrate that the construction of highly linear systems using these type of returns is also possible.

In line with some previously used indicator based inputs the HA returns also have the advantage of being less dependent on the number of training epochs used for the neural network. The graph above shows the results using different training epochs from 50 to 1200 and as you can see the variability in results is not very significant throughout the tests. Although there are some important differences across some drawdown periods the final equity values, linear correlation coefficients and Sharpe ratios for the different systems are very similar.

I would also like to point out that profitable systems with HA returns are just as abundant as those found with simple returns as inputs. You can find profitable outcomes with a wide variety of different trailing stop techniques, trading examples and number of input bars used as well as with several different break even points and initial stop loss values. The last image within this post is of another system using HA returns that trades on hour 14 instead of 8 and uses a 52 break-even period on a parabolic trailing stop mechanism.

In the end the HA returns contains a higher amount of information than the simple returns and may prove to be important in the creation of more diverse and profitable machine learning portfolios. If you would like to learn more about how you too can create your own machine learning strategies to trade the Forex market please consider joining Asirikuy.com, a website filled with educational videos, trading systems, development and a sound, honest and transparent approach towards automated trading.