Download MetaTrader 5

Examples: FANN2MQL Neural Network Tutorial

To add comments, please log in or register
MetaQuotes Software Corp.
Moderator
183646
MetaQuotes Software Corp.  

New article FANN2MQL Neural Network Tutorial has been published:

This article has been made to show you how to use neural networks, via FANN2MQL, using an easy example: teaching a simple pattern to the neuralnetwork, and testing it to see if it can recognize patterns it has never seen.

Author: Julien

Rodra Gon
13
Rodra Gon  

WOW. look so complex, i can make the same operation using matlab conect to metatrader in 10 lines...

Julien
33
Julien  
rodragon:

WOW. look so complex, i can make the same operation using matlab conect to metatrader in 10 lines...


it's not complex, just full of comments.

Remove the comments, and you won't get so many lines.

If you could post the equivalent example using matlab in MT4, I would be interested!

MQL4 Comments
16319
MQL4 Comments  

I Installed Fann2MQL in ( Meta Trader\experts\ ),and put [ASNN 1 learner.mq4] in ( Meta Trader\experts\ ), but does not work, why??


Hi,

Thanks a million for your kindness !!I am a very beginner in the programming field. I attached photo,you will see error .
Julien
33
Julien  
fadiforex:
I Installed Fann2MQL in ( Meta Trader\experts\ ),and put [ASNN 1 learner.mq4] in ( Meta Trader\experts\ ), but does not work, why??
When you say it doesn't work, do you mean there's an error? no reaction? could be be more specific?
Lance
81
Lance  

Greetings.


I installed the FANN2.MQL package into the MT4 experts directory as per installation instructions given on the site.

I then installed ASNN 1 learner.mql and ran it on back testing.


It gave a similar display as did yours in the journal. My question is this.

What are we supposed to use the EA in this case for? In other words a journal printing of data it learned through Neural Networking is usable in what way?

Automated-Trading
Admin
102610
Automated-Trading  

Lets check it.

I have compiled ASNN 1 learner.mq4 and attached this custom indicator to EURUSD.

It's designed as custom indicator, but it doesn't plot any graphs. Look at its output at Experts tab.

My settings:

C:\WINDOWS\system32\Fann2MQL.dll
C:\Program Files\MetaTrader 4\experts\include\Fann2MQL.mqh
C:\Program Files\MetaTrader 4\experts\indicators\ASNN 1 learner.mq4

And the output looks as follows:


Julien
33
Julien  
Quantum:

Lets check it.

I have compiled ASNN 1 learner.mq4 and attached this custom indicator to EURUSD.

It's designed as custom indicator, but it doesn't plot any graphs. Look at its output at Experts tab.

My settings:

C:\WINDOWS\system32\Fann2MQL.dll
C:\Program Files\MetaTrader 4\experts\include\Fann2MQL.mqh
C:\Program Files\MetaTrader 4\experts\indicators\ASNN 1 learner.mq4

And the output looks as follows:

It's not supposed to draw any graph, it's just an example of use of the FANN library.

The output you got means it worked.

Automated-Trading
Admin
102610
Automated-Trading  
zenhop:

It's not supposed to draw any graph, it's just an example of use of the FANN library.

The output you got means it worked.

Yes, I see, I just wanted to show readers how to see the results.
Julien
33
Julien  
Quantum:
Yes, I see, I just wanted to show readers how to see the results.
Oh ok, sorry! Thanks!
MQL4 Comments
16319
MQL4 Comments  

Julien, you've done a serious work. I tried to use this indicator and I stumbled over several problems. I'll be much obliged to you if make some clarifications.

After successfully installing Fann2MQL Library, I ran the indicator and it resulted in the same output as yours, from where we can deduct that for UP signal it should signal "1" and for DOWN it should signal "0". When I tried to read the Indicator Buffer through iCustom() function called from an EA it didn't read any of these choices. That was the first problem.

In my second attempt to get a feedback from the indicator or the library, I tried to call the function compute(inputVector) and receive back the result of a prediction via Global Variable like that:

void prepareData(string action, double a, double b, double c, double output) {
double inputVector[];
double outputVector[];
// we resize the arrays to the right size
ArrayResize(inputVector,f2M_get_num_input(ann));
ArrayResize(outputVector,f2M_get_num_output(ann));

inputVector[0] = a;
inputVector[1] = b;
inputVector[2] = c;
outputVector[0] = output;
if (action == "train") {
addTrainingData(inputVector,outputVector) }
if (action == "compute") {
GlobalVariableSet("Prediction",compute(inputVector));}


After that I received the result of the prediction by reading the same variable through an EA, but the result was invariably "0". So my question is how can I get a prediction result from the indicator if not from the IndicatorBuffer? Any idea will be blessed.

Thank you in advance for your attention.

Albert

12
To add comments, please log in or register