How to build a NN-EA in MT4 - page 18

 

Here's A quick question. How would i normalize or scale ( i havent figured out the difference yet ) the values of certain indicators that draw on the graph ... I.E. the ones that have values corresponding to the price. In my past experience ... using values that are greater than 100 in the inputs (Ie. JPY currencies ) or inputs that dont range from 0 to 1 etc dont produce good output for the network. I've tried 2 methods recently ... one subtracts either 100 or 1 from the price and then make it range btwn 0 to 1 ... so on jpy currencies also divided by 10 so it was correct. I didnt like this way ... something to me seems round-about about this method. The other way i did it was to get the highest and lowest values of the currencies and normalize the value from 0 to 1. Let me know what yall think ... thankz in advance

 

nice ... i likes ... can i ask what exactly the array "X" holds?

 

Not sure if it would be useful for you, but here is my code I used to try some time ago. First function is universal normalization, second one is for signals themselves. So, you would probably replace with your own one(s). Let me know what you think

int Inputs = 12;

int G;

double X[];

double NormArray[];

////////////////////////////////////////////////

void init() {

G=Bars-1;

if (G>0)

ArrayResize(NormArray, G);

else

ArrayResize(NormArray, 1);

if (G<1) {Print("Not enough bars in history"); return(0);}

ArrayResize(X, Inputs*2);

// Filling out X and other arrays

for(int X1=0;X1<Inputs;X1++)

Norm(X1);

}

// Normalized Input function

double Input(int inp1, int shift1) {

N1=

(2/(X-X))*BulkInput(inp1, shift1)+(1-(2/(X-X))*X);

return(N1);

}

// Real Input function

double BulkInput(int inp, int shift) {

double ret;

if (inp==0) {

ret = iMA( Symbol(),0, 233, 0 , MODE_EMA, PRICE_CLOSE, shift)

-iMA( Symbol(),0, 233, 0 , MODE_EMA, PRICE_CLOSE, shift+1);

}

else if (inp==1) {

ret = iMA( Symbol(),0, 192, 0 , MODE_EMA, PRICE_CLOSE, shift)

- iMA( Symbol(),0, 192, 0 , MODE_EMA, PRICE_CLOSE, shift+1);

}

else if (inp==2) {

ret = iMA( Symbol(),0, 144, 0 , MODE_EMA, PRICE_CLOSE, shift)

- iMA( Symbol(),0, 144, 0 , MODE_EMA, PRICE_CLOSE, shift+1);

}

else if (inp==3) {

ret = iMA( Symbol(),0, 105, 0 , MODE_EMA, PRICE_CLOSE, shift)

- iMA( Symbol(),0, 105, 0 , MODE_EMA, PRICE_CLOSE, shift+1);

}

else if (inp==4) {

ret = iMA( Symbol(),0, 89, 0 , MODE_EMA, PRICE_CLOSE, shift)

- iMA( Symbol(),0, 89, 0 , MODE_EMA, PRICE_CLOSE, shift+1);

}

else if (inp==5) {

ret = iMA( Symbol(),0, 55, 0 , MODE_EMA, PRICE_CLOSE, shift)

- iMA( Symbol(),0, 55, 0 , MODE_EMA, PRICE_CLOSE, shift+1);

}

else if (inp==6) {

ret = iMA( Symbol(),0, 36, 0 , MODE_EMA, PRICE_CLOSE, shift)

- iMA( Symbol(),0, 36, 0 , MODE_EMA, PRICE_CLOSE, shift+1);

}

else if (inp==7) {

ret = iMA( Symbol(),0, 21, 0 , MODE_EMA, PRICE_CLOSE, shift)

- iMA( Symbol(),0, 21, 0 , MODE_EMA, PRICE_CLOSE, shift+1);

}

else if (inp==8) {

ret = iMA( Symbol(),0, 13, 0 , MODE_EMA, PRICE_CLOSE, shift)

- iMA( Symbol(),0, 13, 0 , MODE_EMA, PRICE_CLOSE, shift+1);

}

else if (inp==9) {

ret = iMA( Symbol(),0, 8, 0 , MODE_EMA, PRICE_CLOSE, shift)

- iMA( Symbol(),0, 8, 0 , MODE_EMA, PRICE_CLOSE, shift+1);

}

else if (inp==10) {

ret = iMA( Symbol(),0, 5, 0 , MODE_EMA, PRICE_CLOSE, shift)

- iMA( Symbol(),0, 5, 0 , MODE_EMA, PRICE_CLOSE, shift+1);

}

else {

ret = iMA( Symbol(),0, 3, 0 , MODE_EMA, PRICE_CLOSE, shift)

- iMA( Symbol(),0, 3, 0 , MODE_EMA, PRICE_CLOSE, shift+1);

}

return (ret);

}

void Norm(int input1) {

A=0; B=0;

for (int X2=0;X2<G;X2++)

NormArray[X2] = BulkInput(input1, X2);

ArraySort(NormArray);

A=NormArray[0];

B=NormArray[G-1];

X=A;

X=B;

//Print ("Finished Norm");

}

jasondavis87:
Here's A quick question. How would i normalize or scale ( i havent figured out the difference yet ) the values of certain indicators that draw on the graph ... I.E. the ones that have values corresponding to the price. In my past experience ... using values that are greater than 100 in the inputs (Ie. JPY currencies ) or inputs that dont range from 0 to 1 etc dont produce good output for the network. I've tried 2 methods recently ... one subtracts either 100 or 1 from the price and then make it range btwn 0 to 1 ... so on jpy currencies also divided by 10 so it was correct. I didnt like this way ... something to me seems round-about about this method. The other way i did it was to get the highest and lowest values of the currencies and normalize the value from 0 to 1. Let me know what yall think ... thankz in advance
 
jasondavis87:
nice ... i likes ... can i ask what exactly the array "X" holds?

Jason,

I edited my previous post and I think I included everything this time. Normalization is very important task by the way. Let me know how it goes.

 

Good EA

Designing a profitable EA might just be a simple task my EA can do something for you at fxliberty dot com.

 

Awesome i'll check this out when i get home from work ... thankz

 

Ok Quick question ... this seems to be what i get from the code ... in laymans terms:

you have a set of MA's that need to be Normalized ...

X = the high and X = the low ( differences between MA - Prev)

And you use those values to normalize the MA - Previous MA value between [0,1]

is that correct?

 

Right...

Orest

jasondavis87:
Ok Quick question ... this seems to be what i get from the code ... in laymans terms:

you have a set of MA's that need to be Normalized ...

X = the high and X = the low ( differences between MA - Prev)

And you use those values to normalize the MA - Previous MA value between [0,1]

is that correct?
 

Awesome ... another quick question ... what are your thoughts on using just the MA Price and not the difference from the previous price ... IE iMA (...) instead of iMA(...,i) - iMA(...,i-1)

EDIT: Nvm ... tried both ... only difference worked ... well sorta ... not getting consistent results ... i know neural networks are random but ... not as random as the results im getting

 

This is what i currently have:

below -80 is a sell signal and above 80 is a buy signal

the Aqua line is a Net w/ the following inputs:

3MA's(8,13,21) PSAR & Bollinger Bands

The Lime line is a Net w/ :

CCI Stochastic, RSI, %R, DeMarker

The Red one is :

MACD, Momentum, Gator

All values are normalized using the same method

The lines are the outputs from the network after training

I'm at a total loss on what to do now

Here's the Pic:

Files:
chart_1.gif  64 kb