# Build Neural Network Indicator in MT4 using Neuroshell

#### arryex

##### Established member
593 6
Hi At120,

Finally I found where is the miscalculation come, the trigonometric calculation described on the SpectralDilation.pdf is based on degree instead of radiant, you should convert 2*pi = 360º or 180 = pi = 3.1415927

For example
b1 = 2*a1*Cosine(1.414*180 / 10);

it shall be written in c code as
b1 = 2*a1*cos(1.414*3.1415927/ 10);

After compiling code on visual c then import dll as indicator on Neuroshell.

You can check also the output of your indicator compare with excel calculation result, as attached here. You can insert the excel data into Neuroshell and then insert your dll indicator compare with excel calculated values.

Afterward, we can create a trading strategy based on stochastic filter. I think this indicator as well as other indicators will not giving successful trade all the time.

#### Attachments

• 84.1 KB Views: 263
• 318 KB Views: 1,957
• 260.7 KB Views: 1,308
• 197.8 KB Views: 789

#### xyz1453

##### Junior member
11 1
I want to apply CH results as inputs for random forest tree algorithm.Should I use the CH predicted values(of indicator , price whatever) or the CH formula as input?

#### arryex

##### Established member
593 6
You can implement in both way:
1. Insert CH result into your Nst then input it into your random forest tree.
2. Insert your formula into Nst (using available indicators), then insert into your random forest tree.
Using method 2 will depend on your capability to implement the formula.

#### Krzysiaczek99

##### Well-known member
430 1
Hi At120,

Finally I found where is the miscalculation come, the trigonometric calculation described on the SpectralDilation.pdf is based on degree instead of radiant, you should convert 2*pi = 360º or 180 = pi = 3.1415927

For example
b1 = 2*a1*Cosine(1.414*180 / 10);

it shall be written in c code as
b1 = 2*a1*cos(1.414*3.1415927/ 10);

After compiling code on visual c then import dll as indicator on Neuroshell.

You can check also the output of your indicator compare with excel calculation result, as attached here. You can insert the excel data into Neuroshell and then insert your dll indicator compare with excel calculated values.

Afterward, we can create a trading strategy based on stochastic filter. I think this indicator as well as other indicators will not giving successful trade all the time.
I checked roofing filter and supersmoother quite deep like a year ago and unfortunatelly using of it was giving more harm then good. if you compare SMA an SS they almost the same just length SMA = length SS/2 or oposite.

Aplying SS to inputs of my AI algos was always giving worse results. So be carefull with it !!!

Krzysztof

#### xyz1453

##### Junior member
11 1
Hi Everybody ,

I am preparing a csv file for Chaos Hunter?How should be the date formation in the csv file?Most recent date (data) should be on the top column or bottom column?Thanks.

#### arryex

##### Established member
593 6
The oldest data at the top and the newest at bottom

#### ionone

##### Junior member
12 3
bridge

hello all

I'm looking for the Neuroshell/MT4 bridge, any good soul would share it, if I may ask? I'm willing to pay a little bit if necessary

thanks a lot

Jeff

Pat494

##### Active member
107 6
I have mt4 bridge for the NS 5.6 , pretty old version but pm me if you need it.

#### ionone

##### Junior member
12 3
thank you so much! after hours of research (litterally) I found the full MT4 bridge on an isolated site and is working like a charm

you have to send 1 units to trigger the bridge (you cannot send for examples 234 units you select the lot on MT4 side and that's it (which is a bit of a problem if you use pyramiding and such)

https://www.mediafire.com/?b6zfsmg1xcycdy7
http://www.4shared.com/rar/U4We3nVkba/datafeedmt4.html
http://www74.zippyshare.com/v/x2ZmMAjh/file.html

If the main DLL keeps dissapeearing you have to add an exception to the DLL in your AntiVirus, also sometimes is it suspiciously erased by your AntiVirus but it's not a real virus inside.

Pat494

#### at120

##### Member
58 0
Hi Arryex,

Thanks for your input and info! I changed the code now.. and it looks good so far.

bye the way, I now have a semi implementation of ChaosHunter in MT4... (MACD Signal, without the DLL from CH)
Testing... ;-))

Bye, AT

#### Attachments

• 136.9 KB Views: 633

#### at120

##### Member
58 0
thanks, but some failure signals... but still working... need more improvement

Bye, AT

#### Attachments

• 170.4 KB Views: 713

1 0
Last edited:

#### kovalrock

##### Junior member
11 1
Thank you for sharing your ideas. It is an interesting topic !

#### gyzhen

##### Newbie
1 0
Question about the training input H1 data.

Hi Arryex,

Thanks for this post. I got a question about the extracted training data using NeuralTrainingsetCreator.mq4.

In this file, the corresponding 1 hour data is extracted using the following code:
h1shift = iBarShift(NULL,PERIOD_H1,iTime(NULL,PERIOD_M15,4),true);
input[15] = gmThreshold((iMA(NULL,PERIOD_H1,5,0,MODE_EMA,PRICE_CLOSE,h1shift)-iMA(NULL,PERIOD_H1,5,0,MODE_EMA,PRICE_CLOSE,h1shift+1))/(Point*10));

As we know, each 1 hour bar span over 4 M15 bars. For a particular M15 bar, the corresponding 1 hour bar may have already contained future information. For example, if the open time of the current M15 bar is 12:00 and the close time is 12:14, then the corresponding H1 bar will open at 12:00 and close at 12:59. When we use the above code to collect the close price or EMA of the H1 bar, it already contained the future information (future trend) for the current M15 bar. Thus can we still use these H1 data as the training input?

Thank you very much.

Develop a Neural Network based indicator has some advantages:
- Indicator may consist of a predicted values, as a leading indicator.
- Neural network training can be performed using available softwares (freeware and commercial are available).
- the trained NN can be implemented as indicator in Metatrader either written neural configuration (weight) or calling the dll.

As a sample of NN implementation, I found the following link as the starting point: http://forums.babypips.com/57970-post1.html
Here I attached all file discussed on above link, basic idea to create the neural net is explained on the file (description.doc).

Using the same idea, I use Neuroshell to train the neural network and implement it in MT4 to create the indicator.

The following steps to build the NN:
1. Prepare the training data,i.e. consist of inputs and outputs for NN. Using MT 4 script to collect the data. Input can be indicators available in MT4 such as EMA, RSI, CCI, WPR etc. The output can be predicted EMA, Close, etc which useful for our trading depend on the NN strategy (back propagation, kohonen, PNN, GRNN, or GMDH).
2. Train the network using neuroshell:
- Create new problem
- Advanced NN: loading the data, define input/ouput, extract data (training and testing), design NN to choose NN strategy, create the dll using run time facilities.
3. Copy the created dll into MT4 folder.
4. Create MT4 indicator which consist of: dll file link definition, NN initiation OpenNet (in MT4 init function), calculate the indicator using FireNet and CloseNet (in MT4 deinit function). FireNet is used to firing the neural network using inputs as defined while preparing the data to get the NN output (predicted data).
5. Improving indicator, in my attachment I use moving average and comparison between the output net to generate trading signal and classifier indicator.
6. Converting MT4 indicator to expert advisor (I need some one to help me to create the EA based on created indicators).

The original MT4 files should been modified due to the format data required on
Neuroshell is different.

Attachment explanations:
- Description.doc (brief description from the originator)
- Data collection script.zip (sample code to collect data)
- Indicator, met file, template including instruction (in zip)
- aa Neurotred.jpg (indicator produced based on Neuroshell dll)
- Neuro Trend Classifier 4H.jpg (improved indicator)