Examples: Using Neural Networks In MetaTrader

 

New article Using Neural Networks In MetaTrader has been published:

This article shows you how to easily use Neural Networks in your MQL4 code taking advantage of best freely available artificial neural network library (FANN) employing multiple neural networks in your code.

Author: Mariusz Woloszyn

 

Hi Emsi

This article is fantastic it encompasses two topics I have been getting ready to tackle on MQ4 namely the interfacing of external software and Neural Networks. Now I can do both at the same time it is a very interesting article. Thanks a lot.

 
Thank you for your feedback. It's nice to know that you like my article. Do no hesitate to send me any comments or patches.
 

Hi Emsi,

This is a brillant work.Can you give an example to a newbie like me how can I apply Fann tool to my indicators, lets say 8-21 EMA cross?Thanks in advance.

 

Hi Emsi,

just to add to other commentators: Thank you for taking the time to explain this so clearly. I have not yet tried this myself but will do so in due course. I just wondered what would be a potential set up for a profitable NN? Do you have any suggestions?

 
This is amazing. Thank you.
 

Hi Emsi


Thank you very much. It is an excellent job and great contribution. 


I have two questions for your MACD sample.

1. The traning inputs are 3 period shifts (3*i) and the signal only one shift. Is there any particular purpose for this?

2. ann_wise_long() and ann_wise_short() functions are same? How FANN identifies the buy or sell signal?


I also think that the better design for general use of the valuble tool. it should be encapsulated most FANN funcations into a library, and only exposes a few necessary functions to end-user, such as fann2_setup, fann2_init, fann2_deinit. I will create a version for you if you don't mind.


Many thanks

 
tandoorichi:

1. The traning inputs are 3 period shifts (3*i) and the signal only one shift. Is there any particular purpose for this?

No, there is no particular purpose. It's just an example.

2. ann_wise_long() and ann_wise_short() functions are same? How FANN identifies the buy or sell signal?

Those functions are not the same. ann_wise_long() starts the loop from i=0 while ann_wise_short() starts with i=1.

I also think that the better design for general use of the valuble tool. it should be encapsulated most FANN funcations into a library, and only exposes a few necessary functions to end-user, such as fann2_setup, fann2_init, fann2_deinit. I will create a version for you if you don't mind.

Honestly I do not agree. Fann2MQL is a wrapper library. Its purpose is to provide as much of FANN functionality as possible. On top of it you can add anything you like and it can be done in pure MQL. That's basically what I did for my purpose as I defined functions like ann_load(), ann_save(), ann_destroy(), ann_run() and anns_run_parallel() and moved them to a separate .mqh file for easy use in different EAs. Those functions hide any internal FANN interface and complexity yet Fann2MQL provides you all the power of FANN (like setting different activation functions) in case you need it.
 

Great job! ;)

Thank you to share it for free!

It's a good starting point to build every kind of neuro filter, with every indicator (1 || +>1) ... ! ;)

I have a question about the Delta parameter, because I started to modifiy the basis indicator from Macd to Jmacd (rev. Jurik).

I encountred some difficult about the right input values for FastMA, SlowMA & SignalMA, but this is only a question of optimization and it is not related to the code you wrote.

But the question is: Delta matters if SaveAnn is true? Or it matters only when SaveAnn is off and NeuroFilter is true?

If I'm not wrong I understand that the NF must be T only if SA is F and viceversa.

In other words: what is the influence of Delta on the function SaveAnn?

Thank you in advance! :)

Federico.

 
Fedecosta:
(...)

But the question is: Delta matters if SaveAnn is true? Or it matters only when SaveAnn is off and NeuroFilter is true?

If I'm not wrong I understand that the NF must be T only if SA is F and viceversa.

In other words: what is the influence of Delta on the function SaveAnn?

The Delta is used to tune the level of neural filter so it is meaningful only if neural filtering is turned on. You can read that out of the code:

if(!NeuroFilter || ann_wise_short()>Delta)

If NeuroFilter is false the expression evaluets to true no matter what is the value of the second part.

SaveAnn on the other hand is used to avoid effect of data snooping. We do not want to train and test on the very same data.

 

Hi Emsi,


How will the new MQL5 affect the Fann to MQL and its functions and wrapping since (I believe) MQL5 will support class structures?

I will try to send you a comment on this.


Thanks

Reason: