17 Oct, 2008
Genetic programming an automated trading agent
Posted by: Milton In: Automation| Neural Networks
Some years back I did some research into Genetic Programming and using it for automated trading. Needless to say it didn’t get the results I was looking for so I gave up relatively quickly. Since then I’ve looked at many other methods of automated trading and now I’m back to Genetic Programming. I’ve learnt more and think with some better input data and looking for the right problem to solve it will hopefully be more successful.
The idea with Genetic Programming is to evolve a computer program in the same way that evolution happens in the real world. So you start with a randomly generated population of which there will be some that are fitter than others, you keep those (survival of the fittest) and have them interbreed thereby passing on features and mutating as well as generating new ones randomly… do this over many many generations and hopefully you end up with a damn smart program which is an expert at trading.
I’ve set a spare computer to spend it’s hours evolving these trading agents, preliminary results appear to be on the way to successful.
Finding the problem to solve appears to be critical, my attempts at generating price prediction agents thus far have been less than spectacular. Generating buy/sell signals seems to be more successful.
Early days still, will update more in the future.
The current best program in the current run is:
(IFGT (- (SMA100[2])(- (/ (ATR5[1])(IFGT (- (4)(- (- (/ (/ (ATR10[2])(IFGT (1.810102)(- (/ (ATR20[3])(SMA50[2]))(* (HIGH[4])(/ (4)(/ (IFGTE (* (* (* (IFGT (ATR5[1])(- (/ (ATR20[3])(SMA50[2]))(IFGTE (HIGH[4])(/ (4)(/ (ATR20[3])(HIGH[1]))))))(SMA10[1]))(SMA10[3]))(5.492882))(CLOSE[2]))(SMA10[3])))))))(IFGT (4)(/ (SMA10[1])(ATR100[1]))))(* (/ (8.307099)(/ (2.057818)(/ (LOW[2])(ATR100[1]))))(ATR10[2])))(HIGH[4])))(2.057818)))(1.782779)))(* (/ (8.307099)(/ (2.057818)(/ (ATR10[1])(ATR100[1]))))(ATR10[2])))
Looks like gobbly gook though it is remarkably more understandable than Neural Networks which are basically just a black box. It will be interesting to see if I can generate a successful agent with GP. I may also try on the same data a Neural Network based agent. Neural Networks do have an advantage in that we can have multiple output nodes where we’re stuck with just one for GP.
Update: I thought I’d post the next fittest agent after the above one so that you can see how a program evolves
(IFGT (- (SMA100[2])(- (/ (ATR20[3])(IFGT (- (ATR20[3])(- (/ (ATR10[1])(IFGT (- (4)(- (- (/ (/ (ATR100[1])(IFGT (2.727904)(- (/ (ATR5[1])(SMA100[2]))(* (/ (/ (ATR10[1])(1.463929))(/ (IFGTE (/ (SMA10[3])(SMA100[2]))(ATR10[2]))(SMA10[3])))(/ (ATR10[1])(1.463929))))))(4))(* (ATR20[3])(/ (16.978725)(/ (1.395991)(/ (LOW[2])(ATR100[1]))))))(ATR20[3])))(ATR10[2])))(/ (/ (ATR10[1])(ATR100[1]))(ATR10[1]))))(SMA100[2])))(1.991408)))(* (/ (8.911259)(/ (2.029770)(/ (ATR10[1])(ATR100[1]))))(ATR10[1])))