Self learning probabilistic neural network (PNN)

 

Thanks to Paco Hernández Gómez (http://www.hernandezgomez.com), it is possible to work up on the idea of self learning PNN. In its original form, there are 2 EAs, 1 for the PNN training and another to trade acording to the examples learned.


What I am trying to do is to combine the learning EA into the trading EA so that it learns by itself.


The attached file is for learning purpose and not for trading, so just take the idea behind it and let's discuss what's right or wrong


-Pasupathi-


RapidForex Managed Funds

http://private.thefxcode.com



            
Files:
 
Dhananjay:

Thanks to Paco Hernández Gómez (http://www.hernandezgomez.com), it is possible to work up on the idea of self learning PNN. In its original form, there are 2 EAs, 1 for the PNN training and another to trade acording to the examples learned.


What I am trying to do is to combine the learning EA into the trading EA so that it learns by itself.


The attached file is for learning purpose and not for trading, so just take the idea behind it and let's discuss what's right or wrong


-Pasupathi-


RapidForex Managed Funds

http://private.thefxcode.com


Hey.. The attached file, when I attach it to a chart it takes its own trades with the specified stop/limit.... I thought it was like an EA you attached and trade manually, to let the EA learn how you're trading and get that programized? I'm a noob with programmin and that... do i have to download the learner elsewhere? Appreciate the help.

 
mank:

Hey.. The attached file, when I attach it to a chart it takes its own trades with the specified stop/limit.... I thought it was like an EA you attached and trade manually, to let the EA learn how you're trading and get that programized? I'm a noob with programmin and that... do i have to download the learner elsewhere? Appreciate the help.

What I meant by self learn is by past patterns, not the way you trade. And the part 'StartTraining(int Shift)' is the part where past bar shifts to learn are fed

 
Dhananjay wrote >>

Thanks to Paco Hernández Gómez (http://www.hernandezgomez.com), it is possible to work up on the idea of self learning PNN. In its original form, there are 2 EAs, 1 for the PNN training and another to trade acording to the examples learned.

What I am trying to do is to combine the learning EA into the trading EA so that it learns by itself.

The attached file is for learning purpose and not for trading, so just take the idea behind it and let's discuss what's right or wrong

-Pasupathi-

RapidForex Managed Funds

http://private.thefxcode.com

This is an interesting topic along the lines I have been working recently. Thanks for starting it. I have been trying to build a neural network with a simple built-in learning algorithm. But, I quickly realized the challenges. The first one is the speed of the learning algorithm. Even genetic algorithm quickly overloads the processor. The proposed pnn is based on the nearest neighbor learning algorithm, which is much simpler than the genetic learning, but requires the storage of a large number of vectors. I wonder if anybody did a statistical study to show how many recent buy/sell cases is enough to predict the next one. My gut feeling tells me that there should be several hundred cases. Calculating euclidean distances between several hundred 60-long vectors may take time. My prior experience with pattern-recognition EA's tells me that the length of the pattern (vector) is very critical and may affect EA's results significantly. The next challenge is choosing the vector elements. Paco Hernández Gómez chose the differences between the close prices of 15 bars apart, which is equivalent to the differences of 15-bar moving averages. The posted backtest results were ecouraging. Did anybody verify his results?

 
Dhananjay wrote >>

Thanks to Paco Hernández Gómez (http://www.hernandezgomez.com), it is possible to work up on the idea of self learning PNN. In its original form, there are 2 EAs, 1 for the PNN training and another to trade acording to the examples learned.

What I am trying to do is to combine the learning EA into the trading EA so that it learns by itself.

The attached file is for learning purpose and not for trading, so just take the idea behind it and let's discuss what's right or wrong

-Pasupathi-

RapidForex Managed Funds

http://private.thefxcode.com

Dhananjay,Thks for your work on this. I am curious - when I use the trainer EA from Gomez, it took quite a long while for the training to be completed. But when I used your demo EA which has both training and execution in one EA, the training is faster - for the same period? Any idea what is happening or is something missing ?

 
ronaldosim:

Dhananjay,Thks for your work on this. I am curious - when I use the trainer EA from Gomez, it took quite a long while for the training to be completed. But when I used your demo EA which has both training and execution in one EA, the training is faster - for the same period? Any idea what is happening or is something missing ?

By default the parameter "TestRange" is set at 50, which means testing backwards is only done for past 50 bars, of course if you set a higher number it'll take longer. It also depends on the duration you used the trainer EA from Gomez, if the period was 1 year, then you have to enter, on a 1H chart for example, 365x24=8760 bars! That will surely take a long time...


-Pasupathi-


RapidForex Managed Funds

http://private.thefxcode.com

 
Dhananjay:

By default the parameter "TestRange" is set at 50, which means testing backwards is only done for past 50 bars, of course if you set a higher number it'll take longer. It also depends on the duration you used the trainer EA from Gomez, if the period was 1 year, then you have to enter, on a 1H chart for example, 365x24=8760 bars! That will surely take a long time...


-Pasupathi-


RapidForex Managed Funds

http://private.thefxcode.com

Thanks for the excellent work. Perhaps you should write an article on this subject.


The PNN seems to be a special case of a nearest neighbor network in which the distance is measured using a Gaussian metric. This involves two math steps that are time consuming. (MathExp and MathPow). One can show that in the limit such nets converge to the Bayes classifier for the problem specified. However, one can also show that using a simple square distance measure (Multiply only), a nearest neighbor net will also converge. Convergence here is in the sense that the net will converge to the Bayes classifier as the number of examples approaches infinity. I do not know which net will converge most quickly, but perhaps the literature contains the answer. A net that converges more quickly than the simple Nearest neighbor uses the K nearest neighbors. (Here K must be chosen beforehand, and plays a part analogous to SIGMA in the PNN). My point is that by using a simpler metric, one may be able to speed calculations, and perhaps use fewer examples for training .(However, the other steps involved, moving pointers, accessing memory, etc. may swamp the metric calculations).


A second comment is that the success of these nets depends on the relative weights of the different dimensions of the input vector. In the example this is not a problem, but if the input consisted, e.g., of the RSI, Stoch and an EA or two, weighting each component becomes more problematical. Does anyone have a good solution to this problem, or is it adequate to simply normalize to mean 0, sigma 1...and just how do you do this on the fly? Maybe one could somehow use another learning algorithm to learn the appropriate weights?

 

Interesting topic people, but I'm not convinced that you are not just (in effect) creating another oscillator indicator..

Sorry to rain on your strawberries :)

-BB-

 
BarrowBoy:

Interesting topic people, but I'm not convinced that you are not just (in effect) creating another oscillator indicator..

Sorry to rain on your strawberries :)

-BB-

Certainly true in some sense. However, this oscillator has a sound theoretical basis (e.g. google uses Bayes classification), assuming that there is some mechanism underlying the price time series that can be characterized probabalistically. If you disallow this assumption, then why are you reading this?

 

MC

> If you disallow this assumption, then why are you reading this?

I like to keep an open mind!

-BB-

 
Fewer examples are possible if only certain occurrences are taken into account for calculations eg MA crosses. This can be defined before the PNN start by looking back a certain number of bars and select the desired occurrences within that number of bars (again eg MA crosses). This can significantly reduce the time taken but may need larger number of bars to look back.
Reason: