During a break from trading, I’ve came up with compelling idea to make my laptop figure out trading strategy for me. I want my PC to learn how to trade using neural network. In this journal I will drop some updates from the project with results as well. Long starting post follows, but still hope you will enjoy.
I’ve started from refreshing my Python vocabulary, setting up the development environment (I have not coded in Python on this laptop yet) and selecting the neural network type.
NEAT algorithm felt like good fit. It is very simple to use and to understand on high level.
Below nice youtube video, in where NEAT neural network teaches itself to play flappy bird (it was an inspiration)
https://www.youtube.com/watch?v=OGHA-elMrxI
Basically, NEAT neural network takes inputs, comes up with its own numbers and recalculate inputs into one or more outputs. For forex, inputs can be datapoints to make a decision (eg. prices, indicators, current unrealized form open trade, info if trade is opened, time of day, etc.) Output will be decision on making an action - open long, open short, close long, close short, do nothing etc.
How such neural network (NN) learn? We implement “fitness function”, so NN knows how it performs. It is nothing more than a result of current network. For trading it is simple - our fitness function is realized gain, which we want to maximize.
We will give inputs, NN will come up with random factors for calculations, produce output, we will evaluate output against our fitness function (gain). Process will be repeated 50-100 times (population of AI traders ) after that, the fittest will survive! Algorithm will select these networks who perform best, take their factors, mutate a little bit and produce new breed (generation) of 50-100 AI traders… rinse and repeat.
Sounds easy, right? It is easy, but it requires good (simple) model to be able to run on laptop within acceptable time I will be sharing more details on the current model in next post.