Forex Factory (https://www.forexfactory.com/)
-   Platform Tech (https://www.forexfactory.com/forum/69-platform-tech)

 webesa Jun 19, 2008 9:19pm | Post# 1

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 neurons, 1 output. The hidden layer activation function in Matlab is tansigmoide, for the output it is linear.
If I plot the NN output with the real price, it shows the NN has predictive power, but with the code I did, it's definitely not working.

The calculated weights of the 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.0047956*Sigmoide_node_1_2-3.4143*Sigmoide_node_1_3+0.27514);

<<

I admit that the NN used non-normalized data (not the best), but the plot of the NN output vs the real value under Matlabd shows it is working, so I really wonder about the activation function...

 brenta929 Feb 2, 2009 6:01pm | Post# 2

Matlab

Are you still working with Matlab? How is your progress? I would be very interested in your results because we have developed a dll file that will connect Matlab and Metatrader. Not much luck with creating a good network in Matlab that isn't shifted.

Let me know!

Brent

 flairflair Jun 22, 2009 2:56pm | Post# 3

i m keen to know how your dll bridged matlab and metatrader. it seems highly possible to build a model in simulink to control metatrader operation or analysis in parallel with every tick. does your nn is real time running with the market or just used it to train a model to fit/optimise the result?

is there any suggestion or guide to learn the above interfacing among matlab,metatrader and dll altogether?

thanks

 yogert909 Jul 16, 2009 7:30pm | Post# 4

I'm interested too in your results. subscribing.

thanks

 andrea182 Jan 27, 2010 2:50pm | Post# 5

ea matlab

2 Attachment(s)
i've done something similar....

I would like to present to all of my work in order to create a group with which to develop the mine ea ....

is a job that took me a long time and I will share with the entire community in part because it is not solely and exclusively mine, but also a greek professor of mathematical analysis ...

My main idea was to move data and synchronize data with Matlab as many of you already know is a useful program in many mathematical functions already developed and very complex to develop mq4 ...

regarding the connection and the sincronizzazzione is already fully present in this guide:
http://articles.mql4.com/440

is explained in very understandable so there should be no problem ....

following the poster is and lets you read the results calculated from matlab ..

I remind you to write a file to buy 8 and 9 for sell ...

through these 2 lines you can write data into the correct folder where you can read mt4

% [Pathstr, name, ext, versn] = fileparts (fullname);% divides the full name
%% Of the file into parts
NewName =% [pathstr '' name '_result' ext];% re-compose the new file name

posters when I can also code for matlab without the primary function, but that which calculates the best sl and tp be set ....

to function as said in another post can give me from 75 to 80% prediction of where it will head towards the price will be delivered only to those who will actively participate in the development ...

calculator.rar = set of matlab functions matlab
MATLAB_EA_TP & SL2 is obviously the ea ....

for the indicator that is used in the guide should not have changed anything in that ...

if you want to traslate my function into mq4 or improve the code my email and msn account is abbaveto89[@]hotmail[.]it
MATLAB_EA_TP&SL2.mq4
matlab_calculator.zip

 Ipndasno Mar 5, 2010 12:36pm | Post# 6

Matlab

Thanks for sharing this info. I have been wanting to do this for some time. I have contacted you by email as well.. I hope to work and share info on this project.

 Bwana Apr 16, 2010 10:42am | Post# 7

1 Attachment(s)
Hi, i used Matlab a lot in grad school.. can you explain to me please what _report3.txt / _report4.txt are and what you mean by "write" to file 8 and 9?

Thanks and looking forward to hearing from you. theroot Jan 5, 2013 9:07pm | Post# 8

Hello, have you tried DLL interface? It's described on http://articles.mql4.com/833 and it works great, you can pass any data array from metatrader as a matrix to matlab.
Inserted Video

 RonaldLL Feb 27, 2013 11:39am | Post# 9

Hello everybody.
I'm now also working with MT4 and have some function that I wrote in Matlab. Through the post http://articles.mql4.com/833, I also want to make a DLL-Wrapper via Borland C++ Builder, but I think some file (and step) are missing from the post. Can someone please tell me how to make a DLL file with Borland, and use it in MT4 successfully?
I hope someone have done this before. thankx.