Cortex neural networks software is an integrated package, built around the scripting engine. It means, that you can write scripts to automate tasks.
Cortex is a general purpose neural network program, it can be used for different tasks. However, as most visitors are interested in neural network forex trading, almost every neural network example that comes with Cortex has something to do with using neural networks for trading.
To some extent, Neural network trading is what Cortex was created for. It includes:
Feedforward Backpropagation Neural Networks, with an easy to use interface and large number of additional features, like charting, for example.
On this site, you will find an example, Neural Network Forex Trading Tutorial, that gives you detailed, step by step instructions.
SOM (Self Organizing Maps, classification neural network) are now included as part of Cortex neural network software. With SOM you can perform network teaching and to use a resulting net for data classification.
On this site, you will find an example, that teaches, step by step, how to use Kohonen Neural Network for FOREX trading.
Genetic computations, when applied to neural networks, result in a powerful data analysis tool. Add here the scripting language, that gives you an ability to write your own genetic algorithms, and you will get amazing results...
On this site, you will find an example, that teaches, step by step, using Neural Network Genetic Algorithm for FOREX trading.
A built-in scripting language, that allows you to perform routine tasks automatically. Loading and converting data, optimizations, creating charts, as well as web pages containing these charts, and much more can be created by scripts, with no interference from the user.
It is worth mentioning, that you can add your own functionality (plug-ins) to Cortex, and call it as you would call a regular function of its scripting language. Currntly, Pie Charts are implemented that way.
Additional features, that include databases, image processing, HTML/XML based forms and data import-export, chartuing and more.
This tutorial illustrates the use of UI (non-scripting) features of Cortex. For the complete information on scripting language,
see scripting tutorial and scripting reference guide.
Without scripting, you will only have access to about 10% of Cortex functionality.
Let's outline the steps that we need to take, to use the Neural Network as the data analysing tool (I assume that you are already familiar with an introduction to neural networks theory). The Cortex will help you to do these steps faster and with less frustration, something you may want to keep in mind while reading.
To do it we need to generate a lag file, and to run the data rows we want to analyze through the Neural Network. The resulting file will have the following columns:
Columns for the input. What we present to the Neural Network.
Columns for the output - what we were trying to predict.
And the prediction: the column(s), generated by the Neural Net.
Here is an example:
As was already mentioned, the Cortex Neural Network Application does just that - and much more (see Cortex Built-in Scripting Language).
Simply download the Cortex archive and unzip it to some folder.
Some programs that you can download from this site can work together. If you want (strongly recommended) this kind of functionality to be available, you should create a common folder, called (recommended) S_PROJECTS, and to unzip all software in this folder. The sub-folders will be created for you automatically during the unzip procedure.
When specifying options in your Winzip software, make sure that all subdirectories (subfolders) are restored. Usually it is the default setting for the WinZip. Installation is complete.
Simply delete the folder containing the Cortex files.
Cortex is distributed as feature-limited shareware.
If you choose to register the Cortex software, you will need to enter the password (provided in the e.mail that you will receive after the registration) into the registration prompt.
The following chapters will walk you through a simple example of using the Cortex Neural Networks Software - we are going to build the stock price predicting net.
The program comes with three sample data file groups - genz.*, msft.* and eurusd.*. First two contain data for Genzyme and Microsoft stocks, the third one contains FOREX (Foreign exchange) quotes for conversion between US dollar and EURO.
From the neural network forecasting point of view, there is no difference between stock market and FOREX (except, stocks sometimes split), whatever you learn for one area, usually applies to the other.
Note that you can specify what are the start and end line patterns,
and how many lines should we skip before and after the start line
pattern. Use it if the data are in the middle of the text file
(for example, the file has a header and a footer).
For this example, leave the first field blank.
If you look inside the GENZ.TXT file, that you have received with the Cortex archive, you will notice that the last line has nothing to do with the stocks - it is some kind of a commercial. This is exactly the way it looked when I got this file from the Yahoo quote server. To deal with the problem (we do not want to feed THESE data to the program!), copy this last line, or at least its beginning, and paste it to the "End line" field of the Input dialog. Now the program will stop extracting the data, when it finds the string you provided.
Important note: the stock quote file that I have downloaded from the Internet contains newest data FIRST. The neural network code (as many other data analyzing packages) expects the newest data LAST. So we need to click the "Reverse" checkbox to make sure data arrays are reversed before we do the processing.
Also note that no matter if the "Reverse" is checked or not, the resulting file that the program will produce, will have records in the same order as the original file had. This way if you have some other program that can work with stock price file having new data at the beginning, it will also be able to work with whatever output we produce with Cortex. Also it is much less confusing, especially when you work with the sequence of files.
What does that mean? Lets say you have a GENZ.TXT file. You checked the "Reverse" box, and then (see below for details) you clicked "Generate LAG file". The resulting lag file will still be reversed. But if you select Date and Close, and click Chart, the program will load the data, and then reverse them.
To put it differently, "reverse" checkbox only works for the current tab in a dialog box. To have it at the next tab, check it there.
Still, if you want, you can use the scripting language instead, it will give you the full control over the data.
The first (after we found the start pattern and skipped extra lines) line will be broken into the column names and presented in the list box for inputs and outputs.
We are going to use past values of the stock closing price, to predict future values.
By the way, "adj" means "adjusted, the file I have is adjusted for stock splits. Some data sources do not have this nice feature - what shall we do then?
One of the possible solutions is to use the Built-in scripting language to pre-process the file.
As we are trying to create a network to PREDICT the future values for the line (represented by data in genz.txt), we need to provide the input in the form of HISTORICAL PATTERNS - not only today's data, but yesterdays, and so on.
The reason we need it is simple. Can we predict the future value of the stock price by the current value ONLY? No. We need to know what the price was yesterday, and the day before yesterday - we need to know what is going on with this price.
We are about to generate what is called a lag file. The idea of the lag file is to represent today's data in the same table, side by side with the data for yesterday and so on. Press the "lag file" button. You will have the file with .lgg extention containing something like:
As you can see, the first value in Close-1 column was removed, and the entire column moved up. For the Close-2, TWO first values were removed and so on. Therefore, each line of this new file contains data for the current day AND data for nine previous days.
Let's select the new inputs.
Select "Adj. Close*-1", "Adj. Close*-2"... "Adj. Close*-9" as inputs and "Adj. Close*" as output. This way we will be using nine PREVIOUS days to predict the coming price.
As you can see, you can specify the number of layers, number of neurons in hidden layers (see Introduction to Neural Networks for details on what the elements of a Neural Net are), one of two activation functions (standard for almost any NN package), and stop criteria, if you want the learning process to stop automatically.
This is just a random selection that we use for our example.
Here you can specify one of two ways of breaking the data to the "learning" and "testing" parts (see Introduction to Neural Networks for details). You can use first N records (patterns) as a "learning" material and the rest - as a "testing" data. Or you can randomly select N % of the data.
The random selection does not work with the prediction - it is called cheating ;) But it works well when you are trying to do a line fitting.
How do we know how many records we have in our .lgg file? We can open the file in a text editor and find out. Or we can click the button on the right from the data entry field. I got 1228 records, and I have decided to use 1000 of them for "learning", and the rest - for the "testing".
The "adjust range" combo box is important if there is a chance for our "test" data to get out from the range where the "learning" data are. To compensate, we can extend the range.
It is safe in our case, as we know that the last 228 records are not out of range of the first 1000. When you deal with the real life computations, it is always a good idea to estimate if, for example, your stock price might hit the historical maximum or minimum, and to extend the range to handle the case when it does.
Select all check boxes and press Run. The Neural Network will begin the learning process. The number of epochs (how many times the entire data set was presented to the network), and the best (smallest) learning and testing errors will be displayed.
As the learning continues, the error (representing the difference between the actual output of the network and the desired output) is decreasing. When we decide that it is small enough (and we can always go back and continue the training) we stop.
The "Apply" tab is an exact copy of a "Input" tab except for the "Chart" and "Apply" buttons. The functionality is different, however.
Select same fields you used as the inputs and outputs.
When you press the "Apply" button, the file with the .apl extention is generated. It contains all data that the input contained, plus extra fields for the output, generated by the Neural Network.
Click the "..." and open the .APL file.
Select the No (record number) as the input and Close and NN:Close as outputs - we are going to plot the Close and Predicted Close together on the same chart, to be able to compare them visually.
It will produce a chart, presenting the "desired output" (Close) vs. the output, produced by the Neural Net.
The following image is created by the undertrained Neural Net. The approximation is not very poor (for a one-day prediction). If you continue training, you will get better results.
Cortex uses SQLite database engine, which means you can create, browse and edit tables, both using scripting language and with program's UI only. It is possible to run SQL statements (again, from menu or from scripting language), which makes storing your data easy.
For details, check the Databases tutorial on our site.
Cortex comes with a powerful scripting language called SLANG. Using SLANG you can achieve much more then with the menus only, you can do an elaborated data preprocessing, you even may consider writing your own SLANG plugins.
If you are a programmer, you might want to access Cortex directly, from your software (keep in mind, that you still can create a plugin that exports data, and it is much easier).
The Cortex program comes with the SP_NN.DLL that is the core of Cortex artificial neural networks data processor. However this DLL expors classes instead of functions, so to work with it you need to be a C++ programmer, and even then it is quite inconvenient.
The Cortex API DLL solves this problem, providing a wrapper that you can use the way most programmers do, through calls to functions exported by this DLL.
For details, check the Programmer's API tutorial.
There are many other features in Cortex application. It can load pages from the Internet, it can parse these pages using regular expression syntax, extracting data according to your requirements.
It has a built-in image processor, so you can process all images in a selected folder, making them sharper, for example.
It can access additional functions in third-party DLLs, so you can write extensions to the built-in scripting language.
And more. As new features are introduced, new samples are added to the ZIP archive, so that you can see it in action.