Automated Trading Strategy #70
7 Strategies Created By Generative AI Using A Genetic Algorithm
Important: There is no guarantee that these strategies will have the same performance in the future. I use backtests to compare historical strategy performance. Backtests are based on historical data, not real-time data so the results shared are hypothetical, not real. There are no guarantees that this performance will continue in the future. Trading futures is extremely risky. If you trade futures live, be prepared to lose your entire account. I recommend using these strategies in simulated trading until you/we find the holy grail of trade strategy.
As a quick reminder, our goal is to find the holy grail of automated trade strategy.
We haven’t found the holy grail yet, but we get closer with every strategy. Click here for the most recent performance chart and links to all strategies. For answers to some FAQs, click here.
Contact: AutomatedTradingStrategies@protonmail.com.
Random person at event: “What do you do?”
Me: “I trade futures and publish a newsletter on automated strategies.”
Random person at event: “Oh really. That’s cool. So like AI stuff?
Me: “No, not AI.”
Random person at event: “But it’s automated?”
Me: “The A in AI stands for Artificial not Automated.”
Random person at event: “Right, but you’re getting help from your computer?"
Me: “Yes.”
Random person at event: “Right, so you’re using AI?!”
We were both perplexed.
This was an actual conversation I had with someone at a fundraiser. Granted we were drinking wine on a rooftop, but it made me realize that AI is a very loose and overused term. It also shed some light on the fact that I’m just a trader with a finance background. I really don’t know anything about all of this AI stuff. So I decided to conduct a deep dive into AI. If I’m struggling with its definition and application in trading, no doubt others on the hunt are as well. I hope this post provides us all with some clarity around the subject moving forward.
Strategy 70 is actually seven strategies created by Ninjatrader’s generative AI tool. In addition to giving you the downloads for these strategies, I’m also going to do what I can to help explain what applications AI might have for trading now and in the very near future.
What is Artificial Intelligence (AI)?
First, let me preface by saying that my background is in finance and it’s been a long time since I’ve seen the inside of a classroom. This is just my attempt at trying to get my head around what applications AI might have for us on the hunt.
Let’s start with a few quick definitions of the term AI…
For me, artificial intelligence is the intelligence of machines or software as opposed to biological intelligence. Machine learning (ML) is a subset of AI and takes this definition a step further. Not only does it classify and organize the data, but it then generates something new out of that data. In some cases that something new is a prediction about the future. Those predictions are then used to make trading signals. For example, JP Morgan’s AI solution for FX is called DNA (Deep Neural Network for Algo Execution) and is used, among other things, to advise institutional clients on best execution, order routing and liquidity opportunities.
Going back to the definition of AI, if you do a quick search, you’ll get a definition more like this:
Artificial intelligence leverages computers and machines to mimic the problem-solving and decision-making capabilities of the human mind.
-IBM
In the 1960s, what we’re doing today, the use of statistical algorithms, would have been classified as artificial intelligence (AI). Today, the term AI is an umbrella term for ‘machines with the ability to mimic the human mind’. It’s the “mimic the human mind” part that has the oxymoronic effect of making the task both limiting and daunting, especially in the world of trading, but I’ll come back to this later.
Perhaps the most comprehensive definition comes from the federal government. According to the 10 U.S. Code § 2358, artificial intelligence is defined as follows:
With these definitions in mind, I suppose any machine (including your Roomba) can be AI.
What does this mean for trading? From a trading perspective, I am inclined to agree with SEC Commissioner Mark T. Uyeda’s statement on the use of predictive data analytics by broker-dealers and investment advisers. It was largely in response to the federal government’s announcement two days ago regarding AI compliance. Yes, it seems that the nature of generative AI means the creation of a very large black box, and I get that folks are scared by that, but Pandora’s AI Box was opened a long time ago and any regulation made today concerning AI is probably going to be out of date tomorrow.
Going back to the conversation I had at the fundraiser, I suppose ATS is already using AI. I suppose you could even say that this hunt is about leveraging AI to help find the holy grail of automated trading systems. So, where do we go from here?
Before answering that, I want to take a step back to understand how we got here.
The Race: From Zero Latency To Prediction Analytics
Everyone in the market is on the hunt for alpha. This newsletter is on the hunt for alpha via automated trading strategies, but in the late 90’s everyone was on the hunt for alpha via Electronic Communication Networks (ECNs), which spawned the use of algorithms and the development of high frequency trading (HFT). HFT algos rely heavily on arbitrage strategies, which require speed. In other words, the race was largely about speed. Who would be the first to spot a mispriced order? This created a latency race from milliseconds to nanoseconds. When the race hit time zero, it had nowhere to go but into the future: enter predictive analytics. Suddenly, the race is less about latency and more about predictions using generative AI.
Traditional Vs New AI
Traditional AI is primarily used to analyze data and make predictions, while this new wave of AI goes a step further by creating something new.
From an AI perspective, both brute force (traditional) and generative (new) algorithms are techniques used to solve complex problems, but they differ in their approach and methodology.
Brute force is what NT uses for its optimization model in the strategy analyzer. It is an exhaustive method of data analysis that involves systematically checking all possible solutions to a problem. The goal is to find the optimal outcome based on a particular variable like profit factor by using historical data. Nothing new is being created. We’re using AI to solve for X in a massive scenario analysis.
Generative AI models create new and original content. For example, genetic algorithms use a process of natural selection and evolution to create ‘new generations’. This is what NT uses for AI Generate. Other generative AI models that I look forward to exploring are: reinforcement learning models, deep learning models, ensemble methods (decision trees, RNNs), Bayesian models (probabilistic), time series analysis (ARIMA), and variational autoencoders (anomaly detection).
All this AI talk has me thinking about an episode from Star Trek Next Generations: Quality of Life. This is the episode when the character Data—an AI lifeform—feels compelled to fight for the lives of a trio of other AI lifeforms because they exhibit self-preservation behavior. These new AI lifeforms were referred to as Exocomps.
Data decides to test the hypothesis. To his dismay and disappointment, the Exocomps appear to fail his test (an AI created to mimic humans), but then something happens. Here’s the scene:
For those of you that can’t watch the video, here’s the dialogue:
Data: Perhaps I was wrong in suspecting the Exocomp was alive.
Beverly: This was really important to you, wasn't it?
Data: You said earlier that I am unique. If so, then I am alone in the universe.
When I began investigating the Exocomps, I realized I might be encountering
a progenitor of myself. Suddenly the possibility exists that I am no longer alone. For that reason, I...
The Exocomp has returned.
Beverly: Wasn't it supposed to do that?
Data: In the previous 34 trials, I brought it back after the simulated failure. This time, I neglected to do that.Beverly: I distracted you. Sorry.
Data: Do not apologize. We made a significant discovery.
Beverly: What?Data: It has replicated a different tool. That is not the molecular fuser
it had on entering the tube. Doctor, the Exocomp not only completed the repairs, it also deactivated the overload signal.
Beverly: I thought this was just a simulation.
Data: It was, and the Exocomp must have realized that. It saw that there was no real danger and completed the repairs.
Beverly: And replicated the correct tool to eliminate the false signal.
Data: I see no other possible explanation.
Beverly: The Exocomp didn't fail the test, it saw right through it.
When Data investigates the Exocomps, he finds that they not only repaired the malfunction, but the false alarm created by him as well. Data concludes that the Exocomps possess self-preservation instincts and are therefore sentient.
I’m not sure that self-preservation automatically translates into self-awareness, but I understand the reasoning. What did—and still does—resonate with me is the ability to create or ‘generate’ something new—something that no human (or machine programmed to mimic a human) could think of.
I suppose what I’m looking for is a kind of Trading Exocomp. I’m looking for a tool that has the ability to disregard the indicators I’m using in search of its own; a new tool, a new paradigm or dimension for technical analysis. Does this tool exist today? Please let me know in the comments if you think it does. Meanwhile, let’s look at some practical applications of AI in trading.
Practical Applications of AI in Trading
I am obsessed with generative large language models (LLMs) like ChatGPT. Even though the answers on ChatGPT are only right 50% of the time, it’s no different from talking to a politician at a fundraiser. Some answers are completely made up in what are referred to as ‘hallucinations’ (thank you for explaining that to me Zhivko Zhelev), while other answers provide you with an incredible degree of insight.
The idea behind algos that use alternative data is to use LLMs or Natural Language Processing (NLP) to data-mine financial or economic news. The technology must then be trained to recognize familiar conversation and human sentiment to provide a signal.
For example, an AI Language model could feasibly provide order placement commands like the following:
“Place a market order to buy 10 contracts of ES futures."
"Enter a limit order to sell 1 contract of NQ at 15,560."
"Buy 5 lots of EUR/USD at the current market price."
It could also help with regard to indicator usage:
Calculate the moving average of the last 50 bars of the current instrument."
"Plot the Bollinger Bands using a period of 20 and standard deviation of 2."
"Apply the Relative Strength Index (RSI) indicator to the current chart."
It could also help with the retrieval of account information:
"Get the account balance and equity."
"Retrieve the open positions and their respective profit/loss."
"Check the current margin requirements for trading the selected instrument."
It could also be used to help pull historical data:
"Retrieve the last 500 bars of NQ futures on a daily timeframe."
"Load historical data for the EUR/USD forex pair from January 1, 2022, to February 1, 2022."
"Export the historical tick data for the current instrument to a CSV file."
It could even be used to help with strategy management:
"Start Strategy 69 on the current chart."
"Stop the execution of all active strategies."
"Modify the parameters of Strategy 65 to use a standard deviation of 1.5."
At the very least these commands would make trading faster and easier to learn. It could even be used to provide fundamental analysis with the use of ratings and qualitative data on trades with longer time frames.
The bad news is that AI language models seem to be a few years off from being reliable, but I have no doubt that programming a model to make order commands based on a specific market domain would be much easier than one that must converse with anyone in the world, on any subject.
The good news is that we don’t really need an AI language model for trading. It’s really just an accessory, like skin or facial hair. If I’m honest, the real question we want to answer comes down to one thing: can it predict the close of the next bar? And I want to make that distinction here. I’m not looking for the direction of the next bar, I’m looking for the close of the next bar. How hard could that be when compared against learning how to play Chess or Go?
Easy for me to say, I know. What might this look like?
Wishlist: A Robo Trading Exocomp
In a perfect world, if I could go on a kind of dating app for traders in need of an AI companion, I’d be looking for something very specific. My perfect AI companion would be:
Adept at identifying subtle relationships. Instead of relying on predefined patterns (indicators) I would love to find a deep learning algorithm that could identify relationships that have never been made.
Proficient at pattern recognition. In my opinion, the human brain will always be vastly superior when it comes to pattern recognition, but it would be nice to have an AI counterpart to confirm the signals I’m seeing with either predefined patterns or its own, and some sort of predictive modeling agent to back it up. Predictive modeling can be performed using techniques such as regression and time series analysis.
If I put it all together, I guess I’m looking for a reinforcement learning tool to train an AI companion that can identify subtle relationships, recognize patterns, and predict the close of the next bar in both supervised (known/pre-defined) and eventually unsupervised (unknown/black box) learning. Ideally, to eliminate errors in data, the tool would not be trained on historical data, but rather live data to collect and store. The only input required on my part would be a risk management system of rewards or penalties based on performance. My own little Trading Exocomp.
Does this tool exist today? I think the answer is no. If I’m wrong, please tell me where to find it.
While the perfect AI companion might be hard to find, we do have a tool that can help with the first item on the wishlist; it’s a kind of progenitor to the Trading Exocomp. An AI tool that can identify relationships between pre-defined indicators and create something new from that identification.
It is called AI Generate (AG).
The Trading Exocomp Progenitor: NinjaTrader’s AI Generate
NT’s AI Generate Optimization Model is the next step in our hunt. Sure, the tool may prove to be useless, but it has produced several very interesting strategies that I look forward to testing. The hope, at least on some level, is that strategies created by AI Generate will have better backtest accuracy; that is, there will be less divergence between how the strategy performs in the backtest and how it performs when traded live. Look for updates on actual AI Generate strategy performance in the Mudder Report starting in September.
Those that have been with us for a while know that a large part of the challenge is the NT8 simulation, which will never be as good as the simulation we live in. I believe the human mind is far more capable at finding nuanced patterns (for now), but AI is better at categorizing them and recall. In this way, I truly believe that the holy grail will be conceived by a union of both artificial and biological intelligence, and AI Generate is proof of that potential, however flawed and difficult to use it may be.
Can AI Generate Produce More Accurate Strategies?
When I first started publishing strategies on ATS, all strategies were traded on a range chart. When we started trading those strategies live, less than half performed like the backtest. After some investigation, we found that the calculation for range bars is much harder for the simulation than minute based bars. As soon as we switched to minute based charts, backtest accuracy results improved by ~25%.
Another issue is alpha decay or alpha bleed. This is when the alpha or profitability dries up. What was once a profitable strategy suddenly stops being profitable. This can happen for many reasons, but the best way to fight it is to constantly develop new strategies and new sources of alpha by tweaking existing strategies or creating something new.
So the hope is that not only will AI Generate produce new strategies that we’ve never thought about creating before, and under conditions that may be better suited for the simulation, but that a natural by-product of these AI-generated strategies should be further improvement to backtest accuracy and quite possibly a decrease in alpha decay. How can the simulation produce something that it can’t handle? Perhaps it will close the gap altogether, which would be its own holy grail of sorts.
Before showing you the best strategies that I was able to find using NT’s AI Generate, let’s take a few minutes to review what this tool is and does.