Build Neural Network Indicator in MT4 using Neuroshell

Hi Jon,

As you said your NN has 20 inputs, 1 output and 1 hidden layer with 4 nodes. After opening your MyNN.mat, it shown input weight (4x20), layer2 weight (1x4), input bias (4x1), output bias (1x1). I try to formulate your net as follows (hope I am not making wrong explanation).

Input Layer
Your weight input dimensions are 4 x 20, then formula relation between your inputs to the hidden layer will be
I1*w1-1 + I2*w2-1 + I3* w3-1 +...+I20*w20-1 + b1 for node 1 -> assume as x1
I1*w1-2 + I2*w2-2 + I3* w3-2 +...+I20*w20-2 + b2 for node 2 -> assume as x2
I1*w1-3 + I2*w2-3 + I3* w3-3 +...+I20*w20-3 + b3 for node 3 -> assume as x3
I1*w1-4 + I2*w2-4 + I3* w3-4 +...+I20*w20-4 + b4 for node 4 -> assume as x4

where
w1-1 indicates weight at node 1 from input 1,
w2-1 indicates weight at node 1 from input 2,
...
w1-4 indicates wight at node 4 from input 1, etc
b1 is bias for node 1, b2 bias for node 2 etc..
I1 is input 1, I2 input 2, ... I20 is input 20.

Each node then become input for your transfer function, your transfer function is tansig then node 1 result= tansig(x1), node2 result=tansig(x2), etc.

Your bias size is 4x1 and biasconnect= [1;1] means your bias to be added on input layer and layer 2

Layer 2
You have 1 output, means the formula relation between your hidden layer to your output (your output transfer function is purelin) will be

output=purelin(tansig(x1)* v1-1+tansig(x2)* v2-1+tansig(x3)* v3-1+tansig(x4)* v4-1+b2)

v1-1 is weight layer 2 from node 1
v2-1 is weight layer 2 from node 1
v3-1 is weight layer 2 from node 1
v4-1 is weight layer 2 from node 1
b2 is output bias

Something to add as part of your code is for preprocessing your inputs and postprocessing your output (scaling).

Hope you can coding afterward on your mq4 or dll.
 
Last edited:
Hi Arryex,

Thanks a lot !
Your explanation is very helpfull.

I have been reading back the matlab NN toolbox manual, and it is now quite clear.

What I will do is first to re-code the NN using matrix algebra in matlab, and compare with results from the NN toolbox, making sure these are the same.

Then I think to use Armadillo (Armadillo: C++ linear algebra library) to build the C++ code.

I believe it is even possible to build a dll that can retrieve the NN relevant parameters from a CSV file (saved by matlab) and size the dll NN calculation accordingly.

This would avoid to re-build the dll for every new trained NN with various number of inputs, outputs, nodes, ... and quite helpful for matlab NN based indicator or strategy backtesting in metatrader.

If I succeed (leave me some time, after my full time job :), I share the result here

Thanks again,

Pierre

Hi Jon,

As you said your NN has 20 inputs, 1 output and 1 hidden layer with 4 nodes. After opening your MyNN.mat, it shown input weight (4x20), layer2 weight (1x4), input bias (4x1), output bias (1x1). I try to formulate your net as follows (hope I am not making wrong explanation).

Input Layer
Your weight input dimensions are 4 x 20, then formula relation between your inputs to the hidden layer will be
I1*w1-1 + I2*w2-1 + I3* w3-1 +...+I20*w20-1 + b1 for node 1 -> assume as x1
I1*w1-2 + I2*w2-2 + I3* w3-2 +...+I20*w20-2 + b2 for node 2 -> assume as x2
I1*w1-3 + I2*w2-3 + I3* w3-3 +...+I20*w20-3 + b3 for node 3 -> assume as x3
I1*w1-4 + I2*w2-4 + I3* w3-4 +...+I20*w20-4 + b4 for node 4 -> assume as x4

where
w1-1 indicates weight at node 1 from input 1,
w2-1 indicates weight at node 1 from input 2,
...
w1-4 indicates wight at node 4 from input 1, etc
b1 is bias for node 1, b2 bias for node 2 etc..
I1 is input 1, I2 input 2, ... I20 is input 20.

Each node then become input for your transfer function, your transfer function is tansig then node 1 result= tansig(x1), node2 result=tansig(x2), etc.

Your bias size is 4x1 and biasconnect= [1;1] means your bias to be added on input layer and layer 2

Layer 2
You have 1 output, means the formula relation between your hidden layer to your output (your output transfer function is purelin) will be

output=purelin(tansig(x1)* v1-1+tansig(x2)* v2-1+tansig(x3)* v3-1+tansig(x4)* v4-1+b2)

v1-1 is weight layer 2 from node 1
v2-1 is weight layer 2 from node 1
v3-1 is weight layer 2 from node 1
v4-1 is weight layer 2 from node 1
b2 is output bias

Something to add as part of your code is for preprocessing your inputs and postprocessing your output (scaling).

Hope you can coding afterward on your mq4 or dll.
 
any body can help me please!!!!! I try to insstall neuroshell 5.6 beta 3, and need serial number and password, i try to insert SN and password from this forum but not work " the serial number has been dissable " help me please.......thanks
 
The serial number should be similar as what ward given to you.. if you bought it.

I do not know if in this forum someone inform how to crack it.. for version 5.6 beta 3 is the most available one..I can but I don't want ..and believe you will not get full performance of software if you are using crack version.

I suggest you to learn from free neural network software: encog, jnns, nutonian eureqa.

any body can help me please!!!!! I try to insstall neuroshell 5.6 beta 3, and need serial number and password, i try to insert SN and password from this forum but not work " the serial number has been dissable " help me please.......thanks
 
Hello Group

Been trying to reach Arryex so that he could provide me with a password ,to open his pdfs

I took a pick at his stats(personal info page) and says that he last engaged in January 29 2012.

Could someone provide me with the password or will I have to wait for Arryex to show up in the groups?

Thank you

Robert
 
Hi Robert,

Please mention which pdf you want to open? I will find the paaword for you.

Arryex

Hello Group

Been trying to reach Arryex so that he could provide me with a password ,to open his pdfs

I took a pick at his stats(personal info page) and says that he last engaged in January 29 2012.

Could someone provide me with the password or will I have to wait for Arryex to show up in the groups?

Thank you

Robert
 
Hello Arry
So glad to see that you got back

Are all of these too much to ask ??

Heheh

Love your work

77184d1267254455-build-neural-network-indicator-mt4-using-neuroshell-multimarket-training-short-report.pdf


77306d1267439546-build-neural-network-indicator-mt4-using-neuroshell-multimarket-calibration.pdf


77310d1267443232-build-neural-network-indicator-mt4-using-neuroshell-predictor-result.pdf


77762d1267816205-build-neural-network-indicator-mt4-using-neuroshell-using-ns2-train-test.pdf


77764d1267816205-build-neural-network-indicator-mt4-using-neuroshell-train-using-ns-predictor.pdf


77788d1267824147-build-neural-network-indicator-mt4-using-neuroshell-using-ns2-train-test-prod.pdf


77872d1267908695-build-neural-network-indicator-mt4-using-neuroshell-full-report-using-ns2-6k.pdf


78086d1268185055-build-neural-network-indicator-mt4-using-neuroshell-net-configuration-review-aaneurotrend17i-report-1-.pdf


78088d1268185055-build-neural-network-indicator-mt4-using-neuroshell-neurodimension-aaneurotrend17i.pdf


78550d1268670832-build-neural-network-indicator-mt4-using-neuroshell-ga-optimization-neural-network.pdf


109642d1302435457-build-neural-network-indicator-mt4-using-neuroshell-find-prediction-strategy-treshold.pdf


127700d1326550371-build-neural-network-indicator-mt4-using-neuroshell-ns2-net-matlab.pdf


-neural-network-indicator-mt4-using-neuroshell-play-mackey-glass.pdf




Thanks a lot

Keep up the good work

Robert
 
Hi Robert,

It is not easy for me to recall all password for the file that have been made since 2010. Then I reprinted all pdf from the source, and give a new password to open.

Please use aryex to open all pdf... Happy reading
 

Attachments

  • Find Prediction Strategy Treshold - newpass.pdf
    603.7 KB · Views: 556
  • GA optimization for Neural Network-newpass.pdf
    774.3 KB · Views: 478
  • Multimarket Calibration - newpass.pdf
    583.6 KB · Views: 344
  • Multimarket Training short report - newpass.pdf
    392.3 KB · Views: 349
  • Net Configuration Review aaNeuroTrend17i (report 1) - newpass.pdf
    77.9 KB · Views: 361
  • Train using NS predictor-newpass.pdf
    448.5 KB · Views: 392
  • ns2 net matlab-newpass.pdf
    1.1 MB · Views: 345
  • NN Design Live Cycle - newpass.pdf
    69.1 KB · Views: 342
  • Neuroshell Predictor result - newpass.pdf
    1.1 MB · Views: 424
  • Neurodimension aaNeuroTrend17i-newpass.pdf
    1.2 MB · Views: 385
  • Using NS2 for Train and Test -newpass.pdf
    771.2 KB · Views: 359
  • Using NS2 for Train Test and Prod-newpass.pdf
    324 KB · Views: 374
Hello Arryex,

Finally I used a different way to interface MATLAB and Meta.
That is called the MATLAB Engine, which interfaces MATLAB using Windows COM

I wrote a DLL for MT4.

In the init function , the MT4 indicator or ea starts a MATLAB command window.
Then, MT4 can assign variables and execute commands automatically as anyone would do from the command line.
Any action requires a few ms + the MATLAB process time.

I used this in an indicator or an ea, including for backtesting
It is very stable and efficient, and provides full access to any MATLAB function, custom scripts or function.

I think this method opens a wide range of possibility.

Attached the DLL C code, DLL binary and MT4 sample script for demo.

Best Regards,




Hi Jon,

As you said your NN has 20 inputs, 1 output and 1 hidden layer with 4 nodes. After opening your MyNN.mat, it shown input weight (4x20), layer2 weight (1x4), input bias (4x1), output bias (1x1). I try to formulate your net as follows (hope I am not making wrong explanation).

Input Layer
Your weight input dimensions are 4 x 20, then formula relation between your inputs to the hidden layer will be
I1*w1-1 + I2*w2-1 + I3* w3-1 +...+I20*w20-1 + b1 for node 1 -> assume as x1
I1*w1-2 + I2*w2-2 + I3* w3-2 +...+I20*w20-2 + b2 for node 2 -> assume as x2
I1*w1-3 + I2*w2-3 + I3* w3-3 +...+I20*w20-3 + b3 for node 3 -> assume as x3
I1*w1-4 + I2*w2-4 + I3* w3-4 +...+I20*w20-4 + b4 for node 4 -> assume as x4

where
w1-1 indicates weight at node 1 from input 1,
w2-1 indicates weight at node 1 from input 2,
...
w1-4 indicates wight at node 4 from input 1, etc
b1 is bias for node 1, b2 bias for node 2 etc..
I1 is input 1, I2 input 2, ... I20 is input 20.

Each node then become input for your transfer function, your transfer function is tansig then node 1 result= tansig(x1), node2 result=tansig(x2), etc.

Your bias size is 4x1 and biasconnect= [1;1] means your bias to be added on input layer and layer 2

Layer 2
You have 1 output, means the formula relation between your hidden layer to your output (your output transfer function is purelin) will be

output=purelin(tansig(x1)* v1-1+tansig(x2)* v2-1+tansig(x3)* v3-1+tansig(x4)* v4-1+b2)

v1-1 is weight layer 2 from node 1
v2-1 is weight layer 2 from node 1
v3-1 is weight layer 2 from node 1
v4-1 is weight layer 2 from node 1
b2 is output bias

Something to add as part of your code is for preprocessing your inputs and postprocessing your output (scaling).

Hope you can coding afterward on your mq4 or dll.
 

Attachments

  • MatllabEngMT4.zip
    151.5 KB · Views: 345
Hi Arry,

I would like to ask you what do you trade ?
Indices, futures, forex ?
 
Hi Pat,

I trade previously on forex and gold, due to my limited availability to watch market all the time, I have been trading only on stock where I enjoy capital gain, dividend as well as stock split...
 
arryex,
you're known experienced with neuroshell.
i want to ask you something, do you find genetic builder is the same as NS?

its using genetic neural network also

the framework, its also using random tons of indicator to be optimized to desired equity curved, with also having out of sample test.

percissely like NS feature when we in "training" mode.

different is, when we use it to MT4, NS we could directly fit it to MT4 with plug in,

in Genetic builder, we just request the software to create source code directly from it, then it goes an ready EA
 
Dear Wd,

Geneticbuilder is similarly working like Eureqa (Newtonian), using GA to predict by defining relation between inputs and output. It will generate equation between inputs and output in any structure and indicators. The inputs are located on the population we defined/selected.

Geneticbuilder, specifically using GA with limitation that the output is highest portfolio and the code generated specifically for MT4. Something that may not available on geneticbuilder is the output could not be customize (only highest profit), could not predict any other indicator (using highest correlation, smallest MSE, etc), or other profit criteria (minimum drawdown, highest profit %, etc). I am not sure if the spread, initial account, leverage, slippage are covered as part of geneticbuilder optimization. The only way to do the OOS test is by running the EA in real time.

in NS, it has certain structure (NN configuration, probably backpropagation turboprof2), but this NN structure as well as its parameters (weight and bias) are hidden for user. Genetic algorithm is used in NS to find the best parameters. The NS output is most vary compare to geneticbuilder (more sophisticated and complete). We can predict an indicator or find highest profitable strategy. What I can mention here is geneticbuilder core is genetic algorithm(GA) but NS consist of GA and neural network.
 
Dear Wd,

Geneticbuilder is similarly working like Eureqa (Newtonian), using GA to predict by defining relation between inputs and output. It will generate equation between inputs and output in any structure and indicators. The inputs are located on the population we defined/selected.

Geneticbuilder, specifically using GA with limitation that the output is highest portfolio and the code generated specifically for MT4. Something that may not available on geneticbuilder is the output could not be customize (only highest profit), could not predict any other indicator (using highest correlation, smallest MSE, etc), or other profit criteria (minimum drawdown, highest profit %, etc). I am not sure if the spread, initial account, leverage, slippage are covered as part of geneticbuilder optimization. The only way to do the OOS test is by running the EA in real time.

in NS, it has certain structure (NN configuration, probably backpropagation turboprof2), but this NN structure as well as its parameters (weight and bias) are hidden for user. Genetic algorithm is used in NS to find the best parameters. The NS output is most vary compare to geneticbuilder (more sophisticated and complete). We can predict an indicator or find highest profitable strategy. What I can mention here is geneticbuilder core is genetic algorithm(GA) but NS consist of GA and neural network.
 
hi arryex,

do you know about tradingsolution? can it generate the same dll like neuroshell 2 ?

Terima kasih
 
Top