Using Neural Networks
This is a step by step example of how to use the
Cortex Neural Networks module with the
MACD and Point and Figure tools.
A known flaw of MACD and
Point and Figure indicators is the fact
that they are late. The stock price moves, and only then they
are producing their advices.
What we are going to do is to use the Neural Network
to predict the stock price and then to use the
MACD or Point and
Figure tools to produce buy or sell signals.
Run Trader. On the "Stocks" pane, click "load all".
The program comes with some sample stock files, and if you need,
you can always use the Stock Downloader
free program to get quotes from the Internet.
Select "ibm" and click the arrow to move it to the left list box.
Click on the IBM in the left list box, so that the Trader can
calculate date range for it. Click "Chart" if you want to see
the graphic.
Click MACD tab.
Uncheck "Reverse signals", and if necessary, specify your own
information in the fields. For example, I put $29 as a broker
comission - you might want to change that to whatever YOUR
broker is charging you.
Check "Use NN" and click the "Edit NN". The Neural Network
window appears. Browse the "Data file" and select the ibm.txt.
Click "Select fields" and for the "Inputs" select Open, High, Low,
Close and Volume. For the "Outputs" select "Close".
Click on the "Lag file". It will create file with the same name
as your "Data file", but with the .LAG extention.
Click "Select fields" again - this time we are going to select
fields from the .lag file. Select for "Inputs": Open-1...Open-4,
High-1...High-4... and so on for all fields. We are using 1 to 9
days delayed inputs to predict non-delayed Close. Then when we
use non-delayed inputs, we will get PREDICTED Close for 1 day
into future. We will not use Volume for this example.
For "Outputs" select Close.
On the next tabs: select 2 as number of neurons in the second layer,
select 450 as number of records, and click "Run" to start
teaching the neural net. You may check the corresponding boxes at
the "Learning" tab, to see the errors as they are changing.
When the error is small enough, click "Stop", go to "Output" tab,
click "Apply" and select ibm.apl file by clicking the "..." button.
Then click "Select fields" and select "No" for input and Close and
NN:Close for output. Click "Chart".
By ploting the Close and predicted Close together, you can see how
good the approximation is. If you are not satisfied, return to
the "Learning" tab and click "Run" to continue teaching the net.
When you are satisfied, click "Save" at the toolbar. The neural
network should be saved to the trader\nn directory.
For more details on using the Neural Networks window, read the
Cortex tutorial.
Close the Neural Net window. Click "Apply NN" to replace the day
end Close with whatever we predicted (to get Close data back,
click the first tab and then click MACD tab again - the stock
quotes will be reloaded). Click "Optimize" to find
the best parameteds for MACD indicator (see above).
Finally, when you want to use the Neural Network with the Trader
TOMORROW, you need to provide it with the new data. To do it,
use the Stock Downloader program.
Keep in mind, that Yahoo stock server does not update stock
quotes immediately - there can be a delay between the end of a
trading day and the moment the last day's price becomes available.
If you want to re-train your Neural Network on the new data (one more
day, one more week...) you can RE-generate lag file by clicking the
button in the Neural Net Window. It will save you from the
need to re-enter inputs and outputs again. Remember that the
Data file for this operation must be IBM.TXT and not IBM.LAG.
The following chart was produced by Trader for IBM stock WITHOUT
the use of Neural Networks. The initial amount was $2000, the
comission was $29 per trade and the slipage was 3%. The total
profit was 87% - we went from $2000 to $3735.
The next chart was produced by Trader for IBM stock WITH
the use of Neural Networks. The initial amount was $2000, the
comission was $29 per trade and the slipage was 3% (same as
before). The total profit was 89.7%.
Important: The NN algorythms are not necessarily
capable of predicting stock prices. It took me quite some time to
find a winning net configuration and there is NO GUARANTEE
that it can be done consistently.