Trading in the FX market using mechanical trading strategies

Neural Networks in Trading: Trading Through Images, Using Histograms and Making it Work :o)

During the past month I have been implementing and experimenting with a new Neural Network (NN) building approach that focuses on training neural networks with the use of trading charts (literally images) instead of inputs based on trading information (such as the OHLC). My first post about this technique described the general idea while my second post described how I made the first practical implementation for this and what possible improvements and experimentation routes I would be following. Today I want to share with you my first practical results for this technique, results which show that the Image based NN technique works and is able to achieve long term profitable results in simulation. These results show that the NN technique is able to find an edge through the use of images, constantly adapting against changes in market conditions (as matter of fact retraining the entire network on every day during the back-test). Through the following paragraphs you will be able to learn more about these first results and what new ideas and experiments I will be trying going forward.

My first experiments with this NN image processing technique were using candlestick pictures at a 50×50 pixel resolution – with auto-scaling – in order to train the neural network to predict the next day’s outcome (bullish or bearish day). These first efforts turned out to be unprofitable through the 25 year tests, because the information contained within the images didn’t seem to be enough for the neural network to generate predictive power. I tried several things in order to improve this results – such as the removal of automatic scaling to remove any normalization of trend magnitude – but this didn’t lead to any substantial improvement in the trading results. I then tried a variety of image sizes (larger and lower canvas) but all the 26 year profitable results I obtained were not reproducible because results were mainly achieved through random chance due to the initial NN weights and an insufficient number of training epochs. At this point it seemed clear that the problem was in the image input, it possibly contained too much irrelevant information that was not depicted in a way that was “clear” enough.

–

–

In order to make the input simple and easier to “understand” for the NN I decided to remove the high and low from the charts and to depict the open and close as lines instead of candlesticks. This method generated clearer graphs in which you had two lines that showed the evolution of price opening and closing values. However this change – although improving the results – could still not generate something that was profitable for the whole 26 year period. At this time it seemed clear that I needed to change the output structure as well because probabilities were not being properly depicted. In order to do this I decided to generate 12 different outputs (instead of 1) and to each output assign the probability of falling within a given volatility/directionality prediction box. The volatility boxes were calculated as percentages of the daily ATR, giving us a good glance at the chances predicted by the NN for a wide variety of outcomes.

For example the histogram above shows you that the NN predicts that the next day has a high probability to be between 0 and 20% of the ATR while it also predict that we can have a result between -20% and 0% with a much lower probability or even a result between 40-60% of the ATR with an even lower probability. This probability histogram gives you information about the way in which the neural network is “thinking” in a similar way as a person does, the NN gauges the current graphic input through its training and shows you the probability for different trading scenarios. The decision to go long, short or avoid trading should therefore be based on this histogram. To implement this in a simple manner I made the NN take a trading decision only if the sum of all values on one side (all bullish or bearish classes) had a probability above 50% while the other side had a probability below 50%. This means that if we have high probabilities on both sides we would avoid trading while an asymmetric probability distribution would generate a trade towards either side (because the NN supports one case strongly against the other).

–

–

This is were I had my first long term profitable result :o) (1987-2012 on the EUR/USD). After all of these changes I managed to get a reproducible 26 year profitable trading outcome that reflects the ability of the above method to properly predict trading outcomes. Now that I have achieved a basic level of profitability it is now time to make experiments with changes in system variables to see how these affect the behaviour of the strategy. Larger training sets, larger training epochs, different canvas sizes, removal of automatic scaling, addition of indicators to the image, addition of more data, etc. One of the areas that intrigues me the most is the addition of the high and low values with inclusion of different colours for each different value. This means that we would get lines with different pixel colours that will be able to give the NN a clear way to differentiate the open, high, low and close from each other in a more literal manner. I am unsure of whether this will work or not but it is definitely interesting to experiment with this.

Right now I am happy to announce that this NN image processing technique works and is able to give at least some degree of long term profitable results. With this basic level achieved it is now time to experiment further and take this system to the next level (including other symbols). If you would like to learn more about neural networks in trading and how you too can implement strategies using this computational technique please consider joining Asirikuy.com, a website filled with educational videos, trading systems, development and a sound, honest and transparent approach towards automated trading in general . I hope you enjoyed this article ! :o)