Inspired by @wilczasty post: Laziest trading project with Neural Networks - #5 by wilczasty
I’ve decided to have a go at using NEAT for FX trading.
I started by going through this youtube series: https://www.youtube.com/watch?v=OGHA-elMrxI
It explains NEAT very well and I’ve used the code he provides as the basis for my own project.
So far I’m testing with 5 inputs and 4 outputs on small data sets 50-500 candles.
Inputs are the open, high, low, close of the most recent candle and the bots current position (long, short or none). Outputs are open long, open short, close long, close short.
My fitness function is simply pips won/lost + an initial balance at the end of the run, but if any bot loses it’s starting balance of 100 pips it is eliminated.
A few questions that I’m considering:
-
How to handle the bots logic. All I could make all of the decisions inside the network, but for me to do that the network has to learn that it can only close trades if one already exists and it can only open trades if none already exist (This is because the extra logic to close one or multiple trades, or manage positions seems like too much right now).
-
Trade entries. Should I buy at the best available price or put an entry order at the high of the previous candle for buy orders and low of previous candle for sell orders.
-
What inputs to use, but I want to get the bot running smoothly and putting out accurate results and graphs so I can track what’s happening before digging into that.
-
How to best train NEAT, There are tons of functions for saving and redeploying models that I’ve not come across before, so lots to learn there to optimise training.
-
How close will the back test match reality? In previous projects I’ve had very profitable back tests that fail miserably in the real world.
Some graphs of what’s going on:
Quick explainer:
The bot enters at the close price of each candle.
Profitable trades have a green background while losing trades have a red background.
Upward arrows show buys, while downward arrows show sells.
This is just the first version, so still plenty to do, but it’s a start.
Comments and thoughts welcome.