Better NN EA development - page 70

 

The cannon ball it is only an example for trying the MLP.

Multi Layer Perceptron is also a classification network like the PNN.

I want to change the SVM with the MLP in my indicator.

I have in my indicator 18 input neurons.

The last version of MLP are also 18 input neurons.

 

Canon-ball problem using a Multi Layer Perceptron in MT4

with 18 input neuron and 27 hidden neuron.

gnuplot

> set style data lines

> plot 'mse_train.txt', 'mse_test.txt'

Files:
 
lvsefa:
Hi Better,

You are here,Thanks for your info.

Could you show us more info about your great ea?Still your ea using PNN?Seems your ea running on EURUSD use pending orders recently?Any information is welcome,thank you.

It turned out that my old trading system did not work profitably during high volatile market. Therefore I stopped trading with the old EA temporarily. The optimization didn't help too, because the EA need about 1 year of 1-min data for learning, but there were no volatile data for enough long period. Secondly, the market changed its behaviour completely, now it is driven by another forces.

I started developing another EA, trying another inputs.

It was launched on my real account in November.

I kept the PNN algorithm, but inputs are different now.

And the new EA works on many currency pairs.

I think that I will use the old EA again when the market calms down. Don't know when it will occur, perhaps even not in 2009.

----------

Alex

 

I experimented also with pending orders, and used them in some subsystems, but I made the conclusion that they do not give the edge as compared with market orders. Results with pending and with market orders are almost the same.

---------

Alex

 

I have found another interesting site (at least for me) about neural networks and financial markets:

Introduction - Prediction using neural networks

Simple and illustrative.

 
Shahin:

(2 systems) GOMEZ PNN & eucleadian matix have the most potential.

Where can i find/read about "eucleadian matix" system? What is it? THNX

 

my experience is that pending order has less chanse to get requotes. while market order has more chanse to get requote if at the moment price is moving fast.

 

PNN Question

Hi, dear forum contributors,

thanks for all your thought and works,

and special thanks to Better(alex topchilo) that started this flame, and for Barnix for his very hard works and his contribution,

I want to ask a Question in Gomez PNN :

Based on dear finimej correction of pnn lib,

as all of you see in the pnn lib code :

if (fx > result) {

result = fx;

resultClass = i;

}

}

return (resultClass);

the result of calculations codes lead to 0=BUY , 1=SELL , and no other class,

we know in Gomez codes he defines only 2 calss (0_bus , 1_sell ) ,

but the Q: for each calculation of PNN_SYSTEM , the PNNClassifyVector(double vector[]) returns one of those 2 class , whyyy?

(there isn't any status that fx < result = -99999999999999999999) thus the comparision result will be 0 or 1,

in many cases the system must be standby(wait) and not trade, this is the 3rd class or non_class that must be inserted in functions (NON_CLASS = NOT_TRADE),

this is one of the Keys of this system,

please share your thoughts,

you will find the better results by this key !!!!!

I am working for completion of it and testing more.

the chart shows the result of back test for non trained time of EU.

trained time: 2009 FEB 01 till 2009 FEB 14 and backtest form 2009 FEB 16 till end of 2009 FEB 19 ,

Regards

OTR

Files:
pnn_2_2.gif  8 kb
 

Here is the original PNNClassifyVector method. As you can see the resultClass veriable initially is assigned to -1 (means do nothing). As you correctly pointed out only 0 and 1 are classified as trading signals.

int PNNClassifyVector(double vector[]) {

double length = ArrayRange(vector, 0);

double result = -99999999999999999999;

// Initialization: if still -1 then do nothing

int resultClass = -1;

double fx[2] = {0, 0};

double classVectorCount[2] = {0, 0};

for (int i = 0; i < ArrayRange(pnn, 0); i++) {

int class = pnn[0];

double classVector[60];

for (int j = 0; j < length; j++) {

classVector[j] = pnn[j + 1];

}

classVectorCount[class]++;

fx[class] += MathExp((-1) * euclideanScalarProduct(vector, classVector) / (2 * MathPow(SIGMA, 2)));

}

for (i = 0; i < ArrayRange(fx, 0); i++) {

fx *= 1 / (MathPow(2 * 3.14159265, length / 2) * MathPow(SIGMA, length)) * (1 / classVectorCount);

if (fx > result) {

result = fx;

resultClass = i;

}

}

return (resultClass);

}

 

Notes,

Orest:
Here is the original PNNClassifyVector method. As you can see the resultClass veriable initially is assigned to -1 (means do nothing). As you correctly pointed out only 0 and 1 are classified as trading signals.

int PNNClassifyVector(double vector[]) {

double length = ArrayRange(vector, 0);

double result = -99999999999999999999;

// Initialization: if still -1 then do nothing

int resultClass = -1;

double fx[2] = {0, 0};

double classVectorCount[2] = {0, 0};

for (int i = 0; i < ArrayRange(pnn, 0); i++) {

int class = pnn[0];

double classVector[60];

for (int j = 0; j < length; j++) {

classVector[j] = pnn[j + 1];

}

classVectorCount[class]++;

fx[class] += MathExp((-1) * euclideanScalarProduct(vector, classVector) / (2 * MathPow(SIGMA, 2)));

}

for (i = 0; i < ArrayRange(fx, 0); i++) {

fx *= 1 / (MathPow(2 * 3.14159265, length / 2) * MathPow(SIGMA, length)) * (1 / classVectorCount);

if (fx > result) {

result = fx;

resultClass = i;

}

}

return (resultClass);

}

Hi Dear Orest,

the fx after calculation will result numeric >= 0

thus it will be > -99999999999999999999 all the times ,

thus it will return 0 or 1 for classification and -1 will not returned at all,

,

I attached the verified version PNN3,

#define TOTAL_CLASS 2

#define NON_CLASS -100

#define CLASS_RATIO 10

double aux ;

double myvar[TOTAL_CLASS] ;

int classes[TOTAL_CLASS] ;

int myi;

for (i = 0; i < TOTAL_CLASS ; i++) classes = i ;

for (i = 0; i < ArrayRange(fx, 0); i++)

{

//fx *= 1 / (MathPow(2 * 3.14159265, length / 2) * MathPow(SIGMA, length)) * (1 / classVectorCount);

fx *= ( 1 / classVectorCount ) ; //* ( 1 / (MathPow(2 * 3.14159265, 0.5 ) ) ) * MathPow(SIGMA, length)) * ;

myvar = fx ;

}

for (i = 0; i < TOTAL_CLASS; i++) // sorting ( descending ) for finding the largest result in myvar[] and its class_num in classes[]

for(j = i+1 ; j < TOTAL_CLASS ; j ++ )

{

if ( myvar < myvar[j] )

{

aux = myvar ;

myvar = myvar[j] ;

myvar[j] = aux ;

myi = classes ;

classes = classes[j] ;

classes[j] = myi ;

}

}

resultClass = NON_CLASS ;

// this is the default return value

if ((myvar[0] > CLASS_RATIO * myvar[1])&& (myvar[0] > result))

// myvar[0] is the largest result and it will checked by myvar[1] for

// enough difference (10 times) to be considered as winner class. it can be done by proper selection of SIGMA but I haven't check yet....

{

resultClass = classes[0];

}

please test it

thanks

OTR

Files:
pnn3.mq4  6 kb
Reason: