Examples: Using Neural Networks In MetaTrader - page 9

To add comments, please log in or register
Lukasz Starczewski
150
Lukasz Starczewski  
Hi, with default settings this ea isn't making any transactions for last month. Is there something else I didn't do?
Ravi Rajangam
36
Ravi Rajangam  

I have been trying to understand this EA for a while and I have no knowledge of Neural Networks or FANN.

But after a week of reading up I finally got the basic concepts. The way I understand it is you are using a sliding window concept(whats called feed forward network?) to input the NN with 10 previous bars(AnnInputs) with three values for each bar and have divided the network into two parts. One dataset for Long trades and one dataset for short trades. And you are using 8 networks for each of them (AnnsNumber).But initially I always had the "arrayresize" error while loading the initial inputs. In the following example from your Neuro MACD Fixed version, the first iteration will result in negative array indexes isnt't it? Say when i =0.

 

void ann_prepare_input()
  {
   int i;
   for(i=0; i<=AnnInputs-1; i=i+3) 
     {
      InputVector[i]=10*iMACD(NULL,0,FastMA,SlowMA,SignalMA,PRICE_CLOSE,MODE_MAIN,i*3);
      InputVector[i+1]= 10*iMACD(NULL,0,FastMA,SlowMA,SignalMA,PRICE_CLOSE,MODE_SIGNAL,i*3);
      InputVector[i+2]=InputVector[i -2]-InputVector[i - 1]; // Modified to  InputVector[i+2]=InputVector[i]-InputVector[i+1]; // Since this is storing the value of the MACD Main - Signal.

     }
  }

 

After this modification, I was able to run the EA with no issues. However I am not able to see the saved ANN files (long or short) :( The debug messages do say that they loaded the ANN files with handler x and saved the ann files with a return value of 0. Any ideas why I can't seem to see the files? I have set the AnnSave to true.

 Similarly I was wondering if you could also feed the volume of the bar as another input to see if it influences the outcome in anyway.

I have been playing around with FANN tool to see if I can load some historical data and after creating the ANN just load it in this EA and see how that pans out. I want to play with FANN tool so I can try different algorithms and their results etc.... Plus the more data you feed the NN the better approximation/decision it can arrive at right? 

I am guessing that you must have used that to arrive at your delta (0.4) values. I understand that this is a very rudimentary EA for demonstration purposes only, but I would like to make it work exactly as documented so I can tinker with it and learn more about it before I start using FANN in my other EA's. I am also a week into learning MQL4 so pardon my ignorance.

But I would appreciate any help on why I can't see the .net files. I have tried commenting out the ann_destroy() etc...

laz
3
laz  

here you go ravi ;)

tested and works...

LoginToMQL4
5
LoginToMQL4  
why save function return -1,what problem can be?
Stanislav Korotky
25180
Stanislav Korotky  
LoginToMQL4:
why save function return -1,what problem can be?
Use GetLastError for details.
Sasa Pucko
407
Sasa Pucko  

in function ann_prepare_input() is big error!

InputVector[i] = 10 * iMACD (NULL, 0, FastMA, SlowMA, SignalMA, PRICE_CLOSE,MODE_MAIN, i * 3);

InputVector[i + 1] = 10 * iMACD (NULL, 0, FastMA, SlowMA, SignalMA, PRICE_CLOSE,MODE_SIGNAL, i * 3);


should be:

InputVector[i] = 10 * iMACD (NULL, 0, FastMA, SlowMA, SignalMA, PRICE_CLOSE,MODE_MAIN, i / 3);

InputVector[i + 1] = 10 * iMACD (NULL, 0, FastMA, SlowMA, SignalMA, PRICE_CLOSE,MODE_SIGNAL, i / 3);


as iMACD shift should be 0,1,2,..... and not 0,9,18....

teamaker
3
teamaker  

echo the inputs as above. following doesn't make sense:


void ann_prepare_input()
  {
   int i;
   for(i=0; i<=AnnInputs-1; i=i+3) 
     {
      InputVector[i]=10*iMACD(NULL,0,FastMA,SlowMA,SignalMA,PRICE_CLOSE,MODE_MAIN,i*3);
      InputVector[i+1]= 10*iMACD(NULL,0,FastMA,SlowMA,SignalMA,PRICE_CLOSE,MODE_SIGNAL,i*3);
      InputVector[i+2]=InputVector[i -2]-InputVector[i - 1];

     }
  }

It should change to:

void ann_prepare_input()
  {
   int i;
   for(i=0; i<=AnnInputs-1; i=i+3) 
     {
      InputVector[i]=   10*iMACD(NULL,0,FastMA,SlowMA,SignalMA,PRICE_CLOSE,MODE_MAIN,i/3+1);
      InputVector[i+1]= 10*iMACD(NULL,0,FastMA,SlowMA,SignalMA,PRICE_CLOSE,MODE_SIGNAL,i/3+1);
      InputVector[i+2]=InputVector[i]-InputVector[i+1]; 
     }
  }

InputVector should start to capturing value from iMACD(1), rather than iMACD(0)


Hely Rojas
300
Hely Rojas  

I Like Fann2MQL, but I find it very restrictive 2 Hidden layers.

int f2M_create_standard(int num_layers, int l1num, int l2num, int l3num, int l4num);

It would be acceptable to extend the DLL and create 3, 4 or 5 hidden layers.

I'm creating an Expert Advisor with self-learning.

80 inputs in layer 1.

82 neurons layer 1 hidden

82 neurons layer 2 hidden

3 outputs.

It works correctly, although a bit slow in debug. The only optimization parameter is Stop Loss and MSE.

Stanislav Korotky
25180
Stanislav Korotky  
Hely Rojas:

I Like Fann2MQL, but I find it very restrictive 2 Hidden layers.

It would be acceptable to extend the DLL and create 3, 4 or 5 hidden layers.

I'm creating an Expert Advisor with self-learning.

80 inputs in layer 1.

82 neurons layer 1 hidden

82 neurons layer 2 hidden

3 outputs.

It works correctly, although a bit slow in debug. The only optimization parameter is Stop Loss and MSE.

According to some researchers (for example, read here) 2 hidden layers are sufficient for classical MLP in almost all tasks. Increasing number of layers will only slow down performance without result improvement.

How to choose the number of hidden layers and nodes in a feedforward neural network?
How to choose the number of hidden layers and nodes in a feedforward neural network?
  • stats.stackexchange.com
Is there a standard and accepted method for selecting the number of layers, and the number of nodes in each layer, in a feed-forward neural network? I'm interested in automated ways of building neural networks.
Stephen Davies
891
Stephen Davies  
Hello, and thank you for your great tutorial! Im looking to learn more about ANN's using this tutorial and code, however I cant seem to get it to compile. Metaeditor4 seems to complain that at line 88 & 116 "path" parameter conversion is not allowed. I have never experienced this error, and after some googling am still at a loss on how to fix it to be able to test out the code. Does anyone have any ideas what might be causing this?
To add comments, please log in or register