Example 5 -

Running ChaosHunter Models in NeuroShell Trader

Top  Previous  Next

Data file:  hd.csv

Model file:  hd.md

Settings file:  hd.work (automatically loads into ChaosHunter when you load the model file)

 

If you own the NeuroShell Trader Professional or NeuroShell DayTrader Professional (release 5.5 or greater), you can use those programs to export data which may be used in ChaosHunter, and also to execute and trade the ChaosHunter models in real time.  You may also use the Historical Quotes Downloader program that comes with ChaosHunter to obtain data from Yahoo! Finance, QuoteMedia, and Google Finance.

 

Export Data and Indicators from NeuroShell Trader

Both NeuroShell Trader Professional versions (NSTP) can output data in text or ASCII file format which ChaosHunter reads. You can output any number of indicators as well as the Open price of each bar by using the NeuroShell Tools -> Export Chart/data menu. Just select "Chart Data Values" and the "File" export destination. The Open value is important because ChaosHunter will calculate profit for models based on entering a trade on the open. Then be sure to select "Export a file for the current chart page only", because ChaosHunter will just operate on one stock (or other issue) at a time.

 

Export Trader data

 

Intraday Files

If you export an intraday data file from NeuroShell Trader and save it as a Space separated ASCII file (.txt extension), the file will not be read correctly in ChaosHunter.  This is because the NeuroShell Trader inserts a space between the date and time of the bar.  The result is that the data doesn't appear in the correct columns.  The solution is to save the file exported from NeuroShell Trader as either a Comma separated ASCII file (.csv extension) or a Tab separated ASCII file (.prn extension).  If you are using daily, weekly, or monthly files, this problem does not occur.

 

Export data from Trader

 

Save the NSTP chart you have made, because it will be easier to insert your ChaosHunter model into this same chart later.

 

Open Data File in ChaosHunter and Create a Model

Now in ChaosHunter, load up the file that was exported. Note that in the beginning of the file some indicators may contain the value of asterisk (*).  In both NeuroShell and ChaosHunter this means the value is missing, which usually occurs because not enough bars are available yet to compute an indicator with some lookback parameter.  It is recommended that you tell ChaosHunter to skip such data rows by selecting the appropriate radio button on the bottom of the ChaosHunter Inputs tab.

 

HD data file in ChaosHunter

 

The original data file displayed in ChaosHunter begins with rows that have missing data.

 

HD scale inputs

Select the data and indicators that you want ChaosHunter to use to construct a formula.  ChaosHunter calculates profit based on entering a trade at the Open, so that is selected as the output in trading models.  Note the check mark for scaling input values is turned on to create a more accurate model.

 

Trading Opt Setup

 

We decided to use a Trading Strategy which computes a value that is compared to a threshold in order to make a buy/sell decision.  We also checked True reversal so that exiting a long trade will automatically enter a short trade and vice versa.

 

Create the Model

Using the Evolution Strategy optimization, ChaosHunter generated a formula that used the Negative Volume Index and CCI indicators as well as the close and a constant value.

 

HD Create model

The next step is to save that formula so it may be used by the NeuroShell Trader.  Use the File menu and select Save Model, but be sure to remember or write down where you saved it, because the model file with a .md extension will have to be copied to the Template folder of your NeuroShell Trader folder unless you save it there originally.

 

HD save model

 

After the model file with the .md extension is stored or copied to the NeuroShell Trader Template folder, you are ready to load the model into NSTP. Load up the chart that you have previously saved, because it already includes all the indicators that you used as inputs to your ChaosHunter model. Go to the Insert menu and select New Indicator. The category you want is External Program and Library Calls, which is usually near the bottom of the list.

 

HD Trader External Library call

 

 

Notice that there are three ChaosHunter Indicators you can insert if you have built a profit based model:

 

HD  3 types of DLLs

 

ChaosHunter Output - this is the actual value of the formula

ChaosHunter Signal - this is a buy or sell signal produced by comparing the output to the buy/sell thresholds

ChaosHunter Equity - this is shows the sum of the profit made by the model

 

Only the Chaos Output is available unless you have made a profit based model. If not, NeuroShell will inform you that you are selecting a "scientific model" when you try to insert the ChaosHunter Signal or ChaosHunter Equity indicators. Such "scientific models" can still be used to trade.  Refer to ChaosHunter with NeuroShell Trader for details on how to use the Output model.

 

ChaosHunter Signal

In this example, we used the ChaosHunter Signal, which tells you whether you should enter or exit a long or short position.  When you insert the ChaosHunter Signal indicator in NeuroShell Trader, you have to fill in the blanks on the indicator parameters, i.e., you have to tell NeuroShell Trader that the high used to calculate the ChaosHunter Trading Signal is equal to the high data stream in the NeuroShell Trader chart.  The same is true for all of the indicators included as inputs to the formula.  Price is set to Open, the value used to calculate profit for models based on entering a trade at the open

 

HD map ChaosHunter indicator

 

You can examine this signal in the Trading Strategy Wizard to make a decision about when to take a position, instead of comparing the ChaosHunter Output to thresholds. The Signal implicitly knows about the thresholds.

 

HD Long Entry rule

The Long Entry rule uses the relational indicator A = B, where A is the ChaosHunter Signal indicator and B = 1.  The Short Entry Rule assigns a value of -1 to B.  When we built the model in ChaosHunter, we specified a true reversal.  The signal starts out at 0 but when trading starts it goes directly between 1 and -1 without ever becoming 0 again. In this case, the switch of signal implicitly signals an exit from the current position simultaneous with an entry into the opposite position.  Because we specified true reversal in ChaosHunter, in the NeuroShell Trader we turned on the option for Long/Short entries exist existing short/long positions on the Trading tab in the Trading Strategy Parameters.  This insures that the results will be the same.

 

HD Trader chart

 

Note also that the ChaosHunter Signal is different than the NeuroShell Trader Position indicator, because the ChaosHunter Signal changes value on the bar before the position is to change. In NeuroShell the position signal does not change until the new position has actually been entered. The ChaosHunter signal is therefore easier to use when building "panel of experts" or "ensemble" system in NeuroShell where an overall strategy makes a final decision based on a number of other systems.

 

ChaosHunter Equity

If you put this indicator into a chart, you will see the equity curve from the beginning of the chart. It will be slightly different than the NeuroShell equity curve because NeuroShell restarts the curve and statistics at the end of the Optimization period and at the end of the Paper Trading period (if any). Also, the NeuroShell equity curve has access to both Open and Close prices and can compute the equity based on the Close of each bar. ChaosHunter has only one price stream in the main program (Open is recommended), so there will be slight differences in the equity curves based upon the two different methodologies.

 

Warning about Different Results in ChaosHunter verses NeuroShell Trader Professional

If you export text files from NeuroShell Trader for processing in ChaosHunter, your input data file may contain missing data, usually marked by an asterisk (*). There is a difference in how ChaosHunter and NeuroShell Trader execute trading models optimized on such data sets. For example, suppose the data file has 5 inputs columns, all of which contain some number of asterisks here and there. Not a lot, but suppose no column has complete data in it. In the ChaosHunter interface on the Inputs tab you select all 5 columns as potential inputs for the formula. You check the option to "Skip rows with missing values". At the start of the optimization the program removes ALL rows which have missing data in all 5 checked columns.

 

After the model is optimized in ChaosHunter, you plug it into the NeuroShell Trader and notice that it produces slightly different results (raw formula output, trading signals, final equity) when compared to what you see in ChaosHunter.

 

The reason is that your final formula may contain fewer inputs than you marked on the Inputs tab. For example, say the final formula evolves with just one input of all 5 potential inputs. The NeuroShell Trader template then asks you for only one input time series (besides the Price time series). When firing such an indicator, NeuroShell removes from consideration rows where that particular input has missing data. It does not remove rows which have missing data in the remaining 4 potential inputs because they are not part of the formula. NeuroShell knows nothing about those potential inputs. As a result, the indicator fires with different input data (there are more rows than there were during optimization), and the formula produces slightly different results which may cause new trading signals, or trading signals to shift or disappear. This may be especially true when the formula evolves with technical indicators included, because they look back in time periods which contain more missing rows.

 

It should be noted that the ChaosHunter itself requires all model inputs to be present in the data file when firing the model. The model remembers all inputs (including all potential inputs) on which it was optimized. If any of the model inputs is missing from the data file, the program will issue a warning that inputs are missing and will not fire the model. This ensures that the results of the optimization session always match the results produced by firing the model.

 

Click here for more information on running ChaosHunter models in NeuroShell Trader.