An AI trading strategy is a set of trading rules written as code by a large language model such as ChatGPT, Claude or Gemini from a description in plain language. The model writes the code quickly, but it cannot tell whether the rules make money. Only a backtest on realistic data with real costs can show that.
Can AI create a trading strategy?
AI can create a trading strategy in the sense that a language model turns rules you describe into working code within seconds. ChatGPT, Claude and similar models know the common indicators, order types and backtesting libraries, and they write Python, Pine Script, MQL5 or C# on request.
What a language model cannot do is know whether the strategy has an edge. It has not run the code on market data, so any profit figure or win rate it mentions is a guess. Treat the model as a fast programmer, and the backtest as the judge.
How do you write a prompt for an AI trading strategy?
A good prompt for an AI trading strategy states every rule a machine needs, in numbers, and names the platform the code is for. Vague prompts produce code that runs but trades something other than what you meant.
- Market and timeframe: for example EURUSD on 15 minute bars.
- Entry rule with exact values: buy when the 20 period EMA crosses above the 50 period EMA at the close of a bar.
- Exit rules: stop loss, take profit, time exit or opposite signal, each with a number.
- Position size: a fixed lot size or a percentage of equity risked per trade.
- Trading hours and filters: sessions, days, news or volatility filters.
- Target platform: the language and the strategy API, so the model does not invent functions.
Ask the model to list its assumptions before the code. Wrong assumptions are easier to spot in a list than in a hundred lines of code.
Why do AI written trading strategies fail in a backtest?
AI written trading strategies usually fail for a small set of repeatable reasons, and each one can be caught before the result is trusted. Most of them are not about the idea but about the code.
| Problem | What it looks like | How to catch it |
|---|---|---|
| Invented functions | Calls to an API method or library that does not exist | Validate or compile the code before the run |
| Lookahead | Trades at the close of the same bar that produced the signal, or uses a future value | Read the entry logic; test on finer data |
| No costs | Profit with zero spread and commission | Set spread, commission and swap in the backtest |
| Wrong units | Pips, points and lots mixed up, stops ten times too wide | Check a few trades on the chart |
| Optimization by chat | Asking the model to improve the result again and again until it fits | Hold back out of sample data and walk forward |
| Claimed results | The model states a win rate or return it never measured | Ignore it; only your backtest counts |
The optimization by chat trap is the subtle one: every round of improving the result on the same data is a step of overfitting, even when no optimizer was involved.
What is MCP and how does it connect AI to a backtester?
MCP, the Model Context Protocol, is an open standard introduced by Anthropic in 2024 that lets AI apps use outside tools and data in a common way. An MCP server offers tools, and an MCP client such as Claude Desktop, Claude Code or Cursor can call them while it works on your request.
For trading, MCP removes the copy and paste step. Instead of pasting code from a chat window into a platform and pasting the errors back, the AI app reads strategies and results from the backtester directly, validates code, and with your permission runs the backtest itself.
| Chat window only | Assistant inside the platform | AI app over MCP | |
|---|---|---|---|
| Writes the code | Yes | Yes | Yes |
| Knows the platform's strategy API | Only what you paste | Yes | Reads it from the platform |
| Checks the code compiles | No, you do | Yes | Yes, through a tool |
| Runs the backtest | No | You start it | With your permission |
| Reads the results | Only what you paste | Yes | Yes, through a tool |
How do you backtest a ChatGPT or Claude trading strategy?
Backtesting a ChatGPT or Claude trading strategy follows the same steps as any other backtest, with one extra check at the start: make sure the code does what you described. A backtest shows how a strategy behaved in the past, not how it will perform in the future.
- Describe the rules in numbers, as in the prompt checklist above.
- Generate the code for the platform you test on, not a generic script.
- Validate it so invented functions and refused imports fail before the run, not halfway through.
- Read the logic against your description, line by line for entries and exits.
- Run it on realistic data with spread, commission and swap. See backtesting costs.
- Test robustness with out of sample data, walk forward analysis and a Monte Carlo simulation.
- Run it on live data without real orders before any money is involved.
How do you build and backtest an AI trading strategy in the Orion Quant Technologies Engine?
In the Orion Quant Technologies Engine you describe the rules in your own words, and the assistant in the editor writes a strategy for this engine. Code that fails validation goes back to the model with the errors, and the fix streams into the same editor. AI Studio puts a chat and a canvas side by side: Check compiles the draft in the engine, Fix hands the compiler's errors back to the model, and Save puts the result in your library.
You can also connect your own model and key: Anthropic, OpenAI, Google, DeepSeek, OpenRouter, or a model on your own machine through Ollama or LM Studio, tried in the order you set. Over MCP, Claude Desktop, Claude Code, Cursor and other MCP clients on your computer read your strategies, your runs and the documentation, validate code without running it and export it. With the switch on in the app they also create and change strategies, download data and run backtests, optimizations and audits with your license. The finished run is graded from A to F by the audit, and live test runs a strategy on the live minute feed and records every signal without an order going anywhere. The engine is in early access through the waitlist.
Frequently asked questions
Is ChatGPT or Claude good at writing trading strategies?
Both write working strategy code quickly when the rules are clear and the target platform is named. Both also make the typical mistakes: functions that do not exist, lookahead in the entry logic, missing costs and confident claims about results they never measured. The quality of the strategy depends on your rules and your testing, not on which model wrote the code.
Can AI predict the market?
A language model like ChatGPT or Claude does not predict prices. It writes code and explains ideas based on its training text, and it has no live view of the market unless a tool gives it one. Any strategy it writes is a hypothesis. Whether that hypothesis held up in the past is what a backtest measures; the future stays uncertain.
What does MCP trading mean?
MCP trading usually means connecting an AI app such as Claude to trading or backtesting software through the Model Context Protocol. The AI app can then read data, strategies and results, and call tools such as validating code or starting a backtest. What it may do depends on the tools the software offers and on the permissions you grant.
Do I need to code to build an AI trading strategy?
No, but you need to think like a programmer: every rule must be exact, with numbers for entries, exits and size. The AI writes the code from that. Being able to read the code helps you catch mistakes, and a platform that validates the code and shows the trades on the chart makes up for much of what you cannot read yourself.
Research and testing only. A backtest shows how rules behaved in the past, not what they will earn. Nothing here is investment advice.