How to create and trade a Neural Network model
Updated on 2011-11-18 03:55:55
|
Here is a simple example that shows you how to create, train and trade a Neural Network Model.
- In QuantShare trading software, open the "Prediction" manager by selecting "AI" then "Prediction"
- In the manager form, click on "Add" to create a new neural network model
- Click on "Next" then update the model parameters (Trading period, symbol(s), time frame...)
Example:
Start Date: 01/01/2005
End Date: 01/01/2011
Time frame: Daily
Symbols: GOOG
Samples: 60% learning, 20% validation and 20% for testing
- Click on "Next" then update the inputs and output for this model
Example:
Inputs: (Create two inputs using the "Add" button)
1- Double click on "Symbol Field", select "Formula" then type "perf(close, 1)". Under "WS", type "3" to create two additional inputs: Daily return one-bar ago and daily return two bars ago.
2- Double click on "Symbol Field", select "Formula" then type "perf(volume, 1)".
Output:
Only one output is allowed per neural network model. The output is the value that should be predicted by the model given the different inputs.
In this example, we would like to predict the next bar return, so we use "perf(close, 1)" as formula.
- Click on "Next" to display the neural network layers
- Click on "Next" to define the strategy associated with this neural net model. This strategy is calculated in each iteration.
Strategy:
Entry Rule: prediction > 0 (Buy Google stock if the predicted one-bar return is higher than 0)
Exit Rule: Click on "Select an Output", select "Use N-Bar Stop", click on "Add", set "Number of bars" to 1 then save the output by clicking on "OK".
- Click on "Next" to choose the stop training conditions
- Under "How to select the best model", select "StrategyMetric" then click on "Next".
- Type the name of the neural network model then click on "Finish"
To train the neural net model, select it in the "Prediction" manager form, and then click on "Train". The "Strategy" tab shows you the strategy's performance for each iteration.
In QuantShare Trading Software, here is how to plot the model predictions on a chart:
- Click on "Add Indicator" (first icon)
- Select "All Indicators", type "predict", select the first indicator, update "Category" and "Name" fields then click on "OK".
To use the Neural Network model in your trading system, type:
rule = Predict("Category Name","Model Name") > 0;
|