- Wamaitha's Newsletter
- Posts
- Backtesting an AI trading bot
Backtesting an AI trading bot
AI + EMA 200
Howdy trader!
I have spent the last couple of days attempting to improve the winrate of our AI model.
The first idea I had was to use the EMA 200 as a trend determinant.
If the price was above the EMA, the assumption would be that we are on an up trend.
If the price was below the EMA , we would be on a down trend.
I implemented the EMA condition on python and did a backtest for all timeframes.
The entire backtest took around 6 hours.
Here are the results:
Asset | Timeframe | Winrate (model only) | Winrate(model + EMA200) |
---|---|---|---|
Crash 1000 Index | 1 day | 52.44% | 35.19% |
Crash 1000 Index | 12 hours | 52.28% | 37.27% |
Crash 1000 Index | 8 hours | 48.85% | 34.05% |
Crash 1000 Index | 6 hours | 51.90% | 32.47% |
Crash 1000 Index | 4 hours | 49.78% | 31.20% |
Crash 1000 Index | 3 hours | 48.26% | 28.49% |
Crash 1000 Index | 2 hours | 48.07% | 25.40% |
Crash 1000 Index | 1 hour | 46.04% | 20.36 |
The backtest on the minutes timeframe was fruitless. The data did not have enough variation when plotted on the lower timeframes. For comparison, here is the plot on a 1 day timeframe:
Plot on a 1 hour timeframe:
You can tell the 1 hour is so compact the model is unable to make out the trend properly.
There are a few things we can try to make this work on the lower timeframes:
Change the normalisation technique. A probable cause of the short candlesticks is that the price difference between two candles is so little that when its normalised, they almost fall on the same range.
Avoid normalisation all together.
Use less bars on a chart.
Use less bars + avoiding normalisation.
For now, I will first focus on trying out the model on the live markets. I will only focus on the timeframes that had more than 50% winrate.
Stay tuned for that!
Download the MT5 trading bot here
Reply