Thread: Neural Networks
View Single Post
  #65 (permalink)  
Old 06-20-2008, 02:15 AM
webesa webesa is offline
Junior Member
 
Join Date: Oct 2006
Posts: 5
webesa is on a distinguished road
Cool Neural Network using Matlab and Metatrader

Hello!

I am using Matlab and developped a neural network for several pairs, but I have issues reprogramming the NN from Matlab to mql4!

For a test, I created a small neural network predicting USDJPY price from price in i+10 and i+20. It has 2 inputs, 3 hidden, 1 output. The hidden layer activation function is tansigmoide, for the output it is linear.
If I plot the NN output with the real price, it shows the NN is working, but with the code I did, it's definitely not working.

The calculated weights of hidden layer are :
[13.8525 -43.4534;
-11.2084 18.4331;
-0.30603 0.01022]

The weights from the hidden to the output are :
[0.0020021 0.0047956 -3.4143]

Bias of the hidden layer :
[13.876;
2.644;
0.083215]

Bias of the output
[0.27514]

The problem must be in the activation function wich should be tan sigmoide. As the price is more than 100, the MathExp(-100) give me something very small...
Here is the interesting part of the code :

>>
double a1=iClose("USDJPY",0,i+10);
double a2=iClose("USDJPY",0,i+20);


//Node (1,1)
double Sum_node_1_1=13.8525*a1 -43.4534*a2+13.876;
double Sigmoide_node_1_1=(1-MathExp(-Sum_node_1_1))/(1+MathExp(-Sum_node_1_1));

//Node (1,2)
double Sum_node_1_2=-11.2084*a1+18.4331*a2+2.644;
double Sigmoide_node_1_2=(1-MathExp(-Sum_node_1_2))/(1+MathExp(-Sum_node_1_2));

//Node (1,3)
double Sum_node_1_3=-0.30603*a1+0.01022*a2+0.083215;
double Sigmoide_node_1_3=(1-MathExp(-Sum_node_1_3))/(1+MathExp(-Sum_node_1_3));

//---- Exit value -----
double Sum_node_2_1=(0.0020021*Sigmoide_node_1_1+0.004795 6*Sigmoide_node_1_2-3.4143*Sigmoide_node_1_3+0.27514);


<<

Thanks for your Help!
Reply With Quote