Machine learning trading algorithm for mean reversion strategy
|Machine Learning (journal) (Photo credit: Wikipedia)|
I have been back testing many strategies and most strategies clearly have profitable periods as well as losing periods. There are always some optimal parameters to be found for any specific period of time. However this does not say anything about the likelihood that these parameters will be optimal in the future. Such testing is always prone to curve fitting, data snooping and the like. So my idea was to use machine learning to figure out when to trade the most basic and commonly used strategies and when not to trade these strategies, without optimizing the parameters of the strategy. This way the strategy can be kept relatively simple and be supported by some fundamental underlying trading principles, while substituting trader discretion with machine learning. By the way, I believe that Machine Learning cannot completely replace trader discretion. It is merely a tool that can help a trader capture many more opportunities. The ML algo itself still needs constant monitoring and sanity checking, which is also discretionary.
So I took a broad cross section of the pairs traded in the currency markets:
eurnzd, eurcad, eurusd, gbpusd, audusd, nzdusd, usdjpy, usdcad, usdchf, eurchf, eurjpy, gbpjpy, gbpchf, eurgbp and euraud.And I ran a 3 year back test on daily data using a simple mean reversion strategy. Here is a graph of the combined trading on all the pairs.
|P&L curve of combined trading basic mean reversion strategy|
I programmed an algorithm that runs through the data of each pair and decides, by looking back on a certain period, if the coming period should be profitable for trading the strategy. And if so, it would trade the simple strategy. Here is the resulting P&L after stress testing the algo.
|P&L curve of combined trading Machine Learning mean reversion strategy|
So I have a positive back tested Machine Learning trading algorithm. Yeah! Now what? What are the next steps? Well,
- I will program the algo to automatically paper trade. It will generate the orders against a live 100% for sure unseen market data. The orders will not be executed, but will be recorded, hence paper trading.
- I will analyse the results, tweak the algo and decide if it is OK consider trading live with real money.
- In the mean time I will have set up a live execution system on a trading api, so I can actually start live trading on a small live account.
- I will trade the algo on a "normal" sized account once the trading on the small account produces the expected results.
- I will allow the strategy to be followed by other traders.
There is still a lot of work to do before the algo can go live and even more before others can follow it. I am wondering if there is any interest out there in following this strategy based on what I have explained so far. If you are interested, please let me know by writing a comment or sending me an email.
I will be happy to explain more or help you out any way I can.