How To Use LLMs To Create Automated Trading Strategies For NT8
Important: There is no guarantee that ATS strategies will have the same performance in the future. I use backtests and forward tests to compare historical strategy performance. Backtests are based on historical data, not real-time data so the results shared are hypothetical, not real. Forward tests are based on live data, however, they use a simulated account. Any success I have with live trading is untypical. Trading futures is extremely risky. If you do trade live, be prepared to lose your entire account. There are no guarantees that any performance you see here will continue in the future. The best way to trade is with a simulated account on live data. I recommend using ATS strategies in simulated trading until you/we find the holy grail of trade strategy. This material is for educational purposes only and should not be viewed as investment advice.
“The rich will get richer, and the poor will do the best they can.”
Eric Schmidt, ex-CEO of Google
The quote above was taken from what has become a “banned” and now famous interview of Eric Schmidt. It is Schmidt’s candid response to a question about the impact of AI on the world economy. Here’s the full interview:
In addition to the quote above, Schmidt also says that the United States needs to become best friends with Canada to meet the energy needs (hydro-power) required for AGI. He also suggests that the gap between large and small model players is growing and may never be closed due to these massive data requirements.
I’m no Eric Schmidt, but I feel like he’s getting a lot wrong.
First, there are more cell phones than people in the world, which means everyone will have access to their own AI super-intelligent companion. I think that drastically levels the playing field.
Second, suggesting that AGI is constrained by energy requirements leaves out the possibility that AI will come up with more efficient ways of doing everything, including a more efficient use of resources for data exchange.
The coding languages used today are for humans — who’s to say that a symbol based coding language isn’t better? There have already been several well known instances of emergent (mutant) behavior between AI, where multiple AI agents develop their own form of communication or language to solve a task more effectively. These emergent communicator protocols could be even more efficient if optimized on resource efficiency, speed, and accuracy over human understanding. Add to that, self-evolving abilities that include error-correcting on a feedback loop that iterates until a task is complete, and you have a world that is hard to conceive of. We haven’t even discussed the potential for a new chip architecture.
When asked why Google missed the boat on AI, Schmidt said the following:
“Google decided that work life balance and going home early and working from home was more important than winning.”
This is the statement that really got Schmidt in trouble. I get what he’s trying to say, but I want to look at the statement from another angle.
I agree that we’re in a period where time is of the essence. I also agree that hard work is a requirement, but AI is providing analysis (legal, financial, etc) and decision making tools that can cut back on countless hours of research if you know how to use them. From AI powered decision-making tools, negotiation bots and brainstorming assistants, to strategic planning agents that are able to analyze vast amounts of data (financial, supply chain) and suggest an optimal path forward in a matter of minutes. I predict that in less than a year we will see these “strategic” AI autonomously manage entire business units, adjusting tactics based on a continuous feed of data. These AIs will be aligned to understand the interconnections between tasks, projects, people, companies and even industries.
Those that adopt AI tools and integrate them into their life will be exponentially more efficient. What may seem like a hard worker is actually a person with a grossly superior tool-set.
So what? What does this any of this have to do with our quest?
I think it’s important for us to stay on top of AI and what impact it’s having on the world of trading. As previously announced, I was supposed to select another trading platform back in May. My initial interest in finding another platform had many agendas. As much as I like NT8, I wanted to explore alternative tool sets. In particular, I was looking for a platform with generative AI/reinforcement learning abilities around strategy development, risk/portfolio management, and portfolio optimization.
Several platforms offered versions of these options (Quantower, QuantConnect, TradingView, T4, R|Trader Pro, MultiCharts, Sierra Charts, with a particular interest in ATAS OrderFlow Trading, MotiveWave, VolFix, BuildAlpha and Trade Navigator among a host of others), but the best required programming knowledge, especially if you wanted to use advanced features. I could not figure out how to get over the ‘programming language’ barrier.
Just as I was about to start learning Python, I decided to try using LLMs to bridge the gap and that process evolved into the framework I used to create Strategy 85.
These Are Exciting Times
When I first started ATS, it was out of boredom and bit of grief. I got together with two other traders during COVID lockdowns and we hammered out a few strategies. While we had no confidence in our programming ability, Ninjatrader filled the gap. To be clear, what attracted NT8 to me and so many other retail traders is that it did not require the need to learn programming.
That was four years ago. Little did I know that in 2024 I would have access to a suite of tools that would allow me to create automated strategies using human language. LLMs have given us the ability to create trade structures that “non-coders” could never do with the Strategy Builder or even with a programmer.
This is truly a golden age for traders. Every day another model is introduced (Devin, Aider, Cursor) that does something better. I am particularly interested in an academic application called Sakana that allows LLMs to conduct scientific research. But getting back to what LLMs can do for trading, a subscriber recently asked about a spread strategy that I discussed about a year ago (thanks for the nudge Cora). I was told the strategy could not be done.
It took a few days, but I figured out how to do it. These are the backtest results for the spread strategy created with the help of two LLMs and NT8:
These are promising results, especially given the time period. Due to the nature of the strategy, the performance data above is only for the dates: 6–30–24 to 8–20–24.
I‘m going to show you the ten steps I used to create Strategy 85. If you get stuck or if something doesn’t work, add a comment below. I’m sure someone else has the same question.
The following is a quick tutorial on how to use LLMs to create strategies for use on NT8, but I’m sure the basic process can apply to most platforms.
I started this process using ChatGPT 4o. I have no doubt that ChatGPT 5 will be better, so I keep checking back, but for now, it takes two to three times longer to create a strategy with ChatGPT4o over Claude. This space changes rapidly, but these are the two LLMs I use for now. When I first started with ChatGPT4o, it took approximately 20 iterations to get the strategy right. Then I took it to Claude and it takes about eight iterations. Here’s the process:
- For NT8, you want to open the Ninjascript Editor and an Ninjascript Output window. These options are available after clicking on the “New” drop-down window in the Task bar.
- Pull up the LLM — I like Claude, but you can try this framework out on any LLM.
- Ask the LLM to create a strategy for you that you can use for NT8. For example, “Please create a spread strategy for me that I can use in NT8.’“ You may want to specify the time frame, market regime, instruments (domains) to use, etc. The more you do, the better your prompt will be. I like to add debugging instructions, but it will prompt you to do this if you need it.
- The LLM will give you code. Copy the code.
- Go to the Ninjascript Editor. Create a new Strategy and delete the contents of the template provided. Paste the code provided by the LLM into the Ninjascript editor.
- Compile the code.
- If it works, you’ll have a new strategy. Look for the strategy in the Strategy Analyzer to run. If it doesn’t, you’ll receive error codes at the bottom of the editor.
- Clip or cut and paste these error codes into Claude. Step 8 is an iterative process. You can clip an image of errors and paste that image into Claude. It will tell you what the errors are and give you new code to enter.
- You may need to repeat this process for a third, fourth, fifth, sixth or even eleventh time. The more complicated the strategy, the longer it will take. If you bump into a big road block, you can try feeding the code into another LLM.
- Add additional parameters, commands or indicators if desired.
As an alternative, you might also try asking the LLM, “Can you help me to create a strategy in NT8 in 5 to 10 steps?” It may even provide better instructions than the list above.
Once the strategy complies, run it on the Strategy Analyzer to see how it performs. I like using the Genetic model first (“keep best results” should be higher than 30 in Settings) to test a wide range of variables. Then I cut and paste those results into Claude and ask for any patterns that might help to narrow down permutations for brute force optimization. Here’s an example of the prompt:
I’d like to optimize using brute force but I need to reduce the parameter settings for fewer permutations. Do you have any suggestions on what those settings should be? I’d like to base it on the patterns observed in the following performance chart.
Then I included the performance chart in the prompt window.
This was the response from Claude:
For the brute force optimization, you might structure your parameters like this:
Entry Spread: 10 to 120, step 10
Exit Spread: 10 to 70, step 5
Period: 5 to 100, step 5
This would give you 12 x 13 x 20 = 3,120 combinations, which should be manageable for most systems to brute force optimize.
I’ve done this enough times to know that the suggestions are sound. You have to think of LLMs like a new hire associate fresh out of B school — check all work until confidence builds over certain tasks. When it comes to pattern recognition on an image or several images (charts, tables, etc), Claude and ChatGPT4o are masterful.
You can also use “Projects” to add a group of files for Claude. This feature was just added a few days ago for me, so it’s new, but I’m looking forward to the functionality.
If you’re looking to take this one step further, try asking Claude to help you build a strategy using Google’s colab as a coding environment. It’s pretty quick to learn and you have more flexibility to work with Python. It also has the ability to act as agent that can access multiple applications. You don’t have to know Python to do this, but it does take some patience.
That’s it. Of course you’re going to run into some roadblocks, but you just have to take a break and come back to it later. Keep pushing through. The quest has become a race and I think LLMs give traders a huge advantage.
For an example of a spread strategy that I created using this process see Automated Trading Strategy 85 on my Substack: Automated Trading Strategies.
The hunt continues…
Please let me know if you have any question/comments/suggestions.
Contact: Celan at AutomatedTradingStrategies@protonmail.com