Well two weeks in and one might say I’ve backpropagated and adjusted my own weights. I am way better off than before but far from turn strategies out like an assembly line.
Here are a few of my key lessons learned from my so far brief experience using AI to develop trading strategies.
Developing A Scoring System
What do you look for in a trading strategy? What makes you look at a sequence of trades and say, “yeah id through my money at it”? This was something I had never really put down on paper before, which may or may not have been a flaw in my process from the get-go. Profit is an obvious answer but in my early testing I found that the AI would optimize for a high win rate (sometimes 100%) and would seriously overfit the data and just take 1 or two trades on the hourly time from over five years. One of my coworkers was working a similar project a few years back and said he had a problem where his AI would literally be afraid to trade. I, not being as well versed as him with the AI side of things have finally caught up and seen firsthand how it played out. The next parameter I used was the profit factor, which has been described as the net profits divided by the net losses. Though this was quite useful it has a similar issue.
So, what else do I value about a trading strategy? The frequency. I do not want the strategy to put a position on once or twice in the back tested time frame. Ok, easy, just increase the score based on the number of trades. Well, these things are designed to find the path of least resistance and they do. My strategies leaned to overtrading and got chopped to pieces by fees or simply optimized to make their score by increasing the frequency not their gains. I wanted it to target a range. Looking back over my trades from the last year I found that each strategy averaged between one and three trades a month. This was a rate I was confident with and would like my future strategies to use.
Two other parameters I found that I really wanted to keep track of were win rate and the ratio of average winner to average loser. What I ended up finding was that these two would nearly complement one another perfectly. Trend following strategies usually have a lower win rate but higher average winner vs average loser (also known as R). While mean reversion strategies often has a higher win rate (sometimes 60%-70% historically) but had a relatively low R (1.2-1.5 in some cases).
So how does one quantify all this together?
I got thinking back to school, specifically the rubrics we were always given for projects and how the grade was broken into subsections that did not have to be weighted equally. Perfect.
As of the time this article was written I was doing an even 40-point split across four different categories, annual percentage yield, frequency, win rate and R. What I found was that the strategies I was currently trading all scored around a 30 as the points for R and win rate nearly always complimented one another.
Now I am still working out the kinks with this rubric and trying to gauge a few other parameters to help smooth things out as there can still be a tendency to overfit if I as the developer do not pay to close attention.
Less Is More
Eager to play with my new toy I wanted to try and use genetic optimization to breath some new life into some of my shelfed and discarded trading ideas. Well let me tell you, that’s an afternoon I’m not getting back.
I quickly coded up an unhealthy number of filters, indicators and exit criteria to try in mass. Let my CPU run on full steam for a few hours and WAM, a heck of an equity curve to behold. Needless to say, I continuously found a solution but none robust enough to warrant actually using. This experiment was fun, and I want o revisit it later with a more educational purpose but for now it was a loss of time.
I found that the best results came from optimizing as few parameters as possible. Still using your own research and market insights is the best place to start. I’ve been going back to Kevin J. Davy’s "ntry and Exit Confessions of a Champion Trader"for some inspiration. I am leaving his parameters relatively intact, though I tend to adjust some for moving to a 24/7 timeframe. I have the AI work on two, and in some rare instances three or four (and this I feel is sometimes too many), parameters but that is it. If I’m using a 200-day moving average as a filter I don’t have the AI optimize that length of that filter for example. I picked it as it’s a relatively standard solution, but I may have it decide weather or not it is worth it to use along with another parameter of the strategy.
Be Realistic
Early on I was setting the range of possible targets for a strategy to between 1 and 250 ATRs. It wasn’t long before it occurred to me that there is seldom a chance, I would ever aim for a 250 ATR target on the hourly and especially the daily time frame or feel compfortable taking anything more then a 10 ATR loss.
The last little observation I want to share is to keep your ranges realistic. If a parameter seems odd or out of place, then it probably is. Using AI puts one at a huge risk of overfitting, something that I am very much so concerned about going forward. Sometimes its best to cut the head off the snake and not let the bot even look at numbers you would feel comfortable using. This will limit your search space as well and potentially speed up convergence on a solution saving you time and your poor compute some clock cycles.
Wrap Up
All in all, this has been something I have been working towards and developing for quite some time. I hope I can use this tool to better my systems and my trading, but I need to keep in mind that I am constantly playing with fire.
Thank you for stopping by! I’ve been hard at work writing up the documentation for my genetic learning library and hope to have it out and version 1.0.0 released on npm soon. I also am working with an artist on a couple of t-shirt ideas so stay tuned for them as well! Trying to keep them funny but classy at the same time.
Until next time. Please remember none of this is to be considered financial advice and that I am merely reflecting and recording my own personal experiences.
Until next time trade responsibly, trade with a plan, trade with a purpose!