"Trading is statistics and time series analysis." This blog details my progress in developing a systematic trading system for use on the futures and forex markets, with discussion of the various indicators and other inputs used in the creation of the system. Also discussed are some of the issues/problems encountered during this development process. Within the blog posts there are links to other web pages that are/have been useful to me.

Pages

Thursday, 9 January 2014

Neural Net Walk Forward Octave Training Code

Following on from my last post I have now completed the basic refactoring of my existing NN Octave code to a "Walk Forward" training regime. After some simple housekeeping code to load/extract data and create inputs the basic nuts and bolts of this new, walk forward Octave code is given in the code box below.

This code is quite heavily commented, but to make things clearer here is what it does:-

creates a matrix of binary features and a matrix of scaled features ( in the range 0 to 1 ) by calling the C++ .oct function "windowed_nn_input_features." The binary features matrix includes the input layer bias unit

RBM trains separately on each of the above features matrices to get weight matrices

uses the trained NN from step 6 to make prediction/classify the most recent candlestick bar and records this NN prediction/classification. Steps 2 to 7 are contained in a for loop which slides a moving window across the input data

finally writes output to file

At the moment the features I'm using are very simplistic, just for unit testing purposes. My next post will show the results of the above with a fuller set of features.

The scaled features ( in the range to 0 to 1 ) are used as probabilities of an input being on or not in the CD1 training. Uniform random numbers are generated and if scaled features > random numbers then the input is set to 1, otherwise to 0. In this way all the inputs are binary with different probabilities. The code I'm using is from Geoff Hinton's Coursera course material.